Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

In a Smalltalk-style message passing system, each object has its own little parser. When you send it a message, the object will parse and interpret it however it wishes. Essentially, you send the object a sequence of tokens, it parses the tokens and generates some executable code that it then invokes.

In C# (or Java), it would look something like this:

    interface Message : IEnumerable<Token>
    {
    
    }
    
    
    public class Foo
    {
    
    	public void Consider(Object sender, Message msg)
    	{
    		//possibly validate sender...
    	
    		Executable result = this.Parse(msg);
    		
    		if(result.IsValid)
    			sender.Consider(result.Execute(this));
    		else
    			sender.Consider(new MethodMissing());
    	}
    	
    	private Executable Parse(msg)
    	{
		//the ability to parse the message depends on the state of this object
	}
    }
The basic idea is that the object is always in control of what it does. Methods are extremely late-bound because the code for the method may not even exist until the object first creates it in response to a received message.

But, the big idea is that an object is just a little computer, and in a computer system, a computer is the smallest thing that you want to recapitulate.



Sounds more like you're describing Smalltalk 72 (http://worrydream.com/EarlyHistoryOfSmalltalk/#p12) than Smalltalk 80. I've written a fair bit of Smalltalk code, and I can't remember seeing something like what you're describing here. It would certainly be possible, but I don't think it's an accurate description of how most Smalltalk code works.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: