[squeak-dev] Re: ANN: NanoTraits v0.5

Andreas Raab andreas.raab at gmx.de
Tue Dec 22 11:15:41 UTC 2009


Igor Stasenko wrote:
> 2009/12/22 Andreas Raab <andreas.raab at gmx.de>:
> 
> And how to determine that
> SomeClass>>methodA
> is actually
> SomeTrait>>methodB
> which in own turn
> SomeOtherTrait>>methodC
> ?

Easy. In v0.6 (attached) we now retain a reference to the original 
compiled method instead of just the original home. Using the original 
trait method you can find out things like:

method := SomeClass>>#methodA.
method originalTraitMethod => CompiledMethod(SomeTrait>>methodB).
method originalTraitMethod originalTraitMethod => 
CompiledMethod(SomeOtherTrait>>methodC).
method originalTraitMethod originalTraitMethod originalTraitMethod => nil

etc. Obviously, the methodHome the same for all of them.

>> - Some previously invalid trait composition are now valid, in particular T -
>> {#x} - {#y} (meaning T- {#x. #y}) as well as T @ {#x->#y} @ (#a -> #b}
>> (meaning T @ { #x -> #y. #a -> #b}.
>>
> T1 - T2?

Left as an exercise for the reader :-) Seriously, it's straightforward: 
First, implement #includesSelector: and #selectorsAndMethodsDo: in 
TraitExclusion so that it works with traits in addition to symbols in 
the list of exclusions. Next, implement #addTraitUser: and 
#removeTraitUser: in TraitExclusion so that it looks for additional 
traits inside the exclusions. Done. That's all. Four methods.

> My primary concern with traits, is lack of system change notification support.
> We need them in deltastreams.

What kind of support is missing? In NanoTraits, almost all of this stuff 
is absolutely trivial because the entire implementation is deliberately 
simple and trying to fit in the existing class kernel.

Some more things new in v0.6:
- We no longer use a method property for the method home since this 
shows in decompiles. Instead we use NanoTraitMethodState (subclass of 
AddlMethodState) which keeps a reference to the original compiled method.
- Support for Monticello. v0.6 is compatible with Berne traits when 
using Monticello.
- Various fixes and a few more isKindOf:'s to avoid interactions with no 
longer used methods

BTW, v0.6 should be considered a release candidate. Unless there are 
bugs that I haven't found yet, I think this version is good to go.

Cheers,
   - Andreas

-------------- next part --------------
A non-text attachment was scrubbed...
Name: NanoTraits-v0.6.zip
Type: application/zip
Size: 26708 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20091222/ac0de587/NanoTraits-v0.6.zip


More information about the Squeak-dev mailing list