[squeak-dev] Re: Instance variable access in superclasses.
dz0004455 at gmail.com
Fri Nov 28 06:26:39 UTC 2008
i like that idea. if i ever manage to make up my own smalltalk, or my own
language, that will defiantly by considered in making it.
On Thu, Nov 27, 2008 at 11:08 PM, Ralph Boland <rpboland at gmail.com> wrote:
> My idea here is too late for squeak but is food for thought
> for the next great object oriented programming language.
> Instead of using a full fledged message send for accessing
> instance variables we could use a compromise.
> Lets say that symbol @ is special and cannot be used as a regular message
> and let var be an instance variable of a class MyClass and used in
> method myMethod.
> Then to access var in myMethod we can write:
> @ var.
> as in:
> ^ @ var
> or even:
> @ var := 5.
> With this notation local variables and instance variable are
> which results in safer and (arguably) more readable code.
> One way of implementing this would be to require that MyClass
> define instance variable var or an error message would be generated.
> The other way of doing this would be to not require that MyClass define
> var. However, if var is not defined, then myMethod would be abstract and
> by MyClass. Instead only subclasses of MyClass that define
> instance variable var could use the myMethod. This would mean that
> of myMethod would need to be compiled for each subclass that defined var.
> If the additional byte code generated was considered too wasteful then
> one could always use regular message sends.
> I would strongly recommend that abstract variables (such as var) and
> methods somehow be clearly marked.
> I would also recommend that, when var is defined in a subclass, symbol @
> placed in front of it to flag that an abstract variable is being made
> as opposed to a brand new instance variable being created.
> (calm) opinions welcome.
> Ralph Boland
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Squeak-dev