[squeak-dev] Re: A Traits question

Jason Johnson jason.johnson.081 at gmail.com
Thu Feb 21 19:48:58 UTC 2008


On Wed, Feb 20, 2008 at 9:55 PM, Andrew P. Black <black at cs.pdx.edu> wrote:
>
> There are alternative ways of solving the problem in itsme213's original
> post.  One would be to give traits private instance variables.  Then the
> trait TCollectionInstVar would be included twice, aliasing the exported
> methods in both cases, to addCar, addHouse, etc.  The name of the instVar
> itself would be private to the trait, and inaccessible from the class — this
> could be implemented by using a genSym for the insVar.   We still loose the
> flattening property, at least in its simplest form, but the idea of
> trait-private inst vars is simpler to understand, I think, than deep
> renaming, and is useful for a lot of applications.  Two applications that we
> thought of in 2002 were a trait that adds locking and a trait that adds
> transactions to an existing class.  The traits would need a place to put the
> lock or to put the Transaction id, and it seems much more elegant to make
> that place private to the trait.

Well, since the above is just an example of true multiple inheritance
it might be worth while to look at how Lisp deals with it in CLOS.



More information about the Squeak-dev mailing list