first class method categories (was Re: WTF is a trait?)
squeak-dev.sourcery at forum-mail.net
Sat Sep 3 22:40:57 UTC 2005
Avi>"... I'd love to see tools that really emphasized this
[method-category-like] view of traits. I want creating a trait to feel
almost exactly like creating a method category: you should just be able to
choose "new trait" from the method category column of a browser, give it a
name, and see it show up there with the other categories. ...I think this
would be a much lower-impact, more familiar way of integrating traits into
the traditional Smalltalk mindset and workflow than treating them as part of
the inheritance hierarchy, as they are now."
Yes, exactly. A Trait should simply be a respository of method definitions
[source code] that get compiled into any class that "implements" that Trait.
So the CompiledMethods are owned by the class, but the method source
pointers are owned by the Trait. Traits should also be composable from
In fact, all method categories should be Traits. For backwards
compatibility, it would probably be necessary for each class to be able to
define its own private name space for method category names, with the
default name of a class's method category being the global name of the
Trait. Or perhaps there should be both global and class-private Traits.
Classes would also need to be able to override the method implementation
defined by an imported Trait, without affecting the "global" version of the
method as defined by the Trait.
More information about the Squeak-dev