[Grace-core] Fwd: Some notes on pattern matching on the wiki

James Noble kjx at ecs.vuw.ac.nz
Thu Jul 7 16:16:53 PDT 2011


> No, I don't think so.  If "private" means "accessible only within this object" then instance variables and methods are lexically in scope inside the object constructor, and can be accessed without self — and consequently without dynamic dispatch.  And, consequently, they can't be overridden (which is why they are private).

Right - but I think we decided we didn't want that meaning of private - rather the "Ruby" semantics.

> Conversely, if you want a subclass to be able to override your method, or your instance variable, then you should use self.  This means that a method is requested and bound dynamically.

yes. 

> Smalltalk code does this most of the time right now, and is very readable.  

Right. I just realised this myself this morning: 
this will be no worse than Smalltalk code that uses accessor methods for all variable accessses
(which I think was once considered good Smalltalk style and hopefully still is?)

Yes it will be less terse than Self & Newspeak & Scala (& EIffel) 
but I think that is also an advantage

> The only place where this rule would be stricter than Smalltalk is in requiring the use of method request (with self.f) in a sub-object to access a field f of a super-object.  

I'm not sure what you mean by super & sub object here? 
(in smalltalk terminology - the a subclass method to access a superclass field?) 

rather than an enclosed / enclosing object?

> The pay-off is that f might not be a field — f can change from a calculated to a stored "feature" and the sub-object wouldn't care.


Right.  Again, Smalltalk code would use accessors for this...

James


More information about the Grace-core mailing list