Traits

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Traits

Nick
Armed with new knowledge of Traits gained from the excellent "Squeak By Example" I tried:
    Smalltalk allClasses select: [:each | each hasTraitComposition]

which gave:

an OrderedCollection(ActionSequence BalloonBezierSimulation BalloonEngine BalloonEngineConstants BasicRequestor Behavior BrowserProvider ....WorldMenuProvider XMLTokenizer ZipConstants ZipFileConstants)

However browsing to a random class say "ActionSquence", doesn't show any evidence of Trait composition. Is this a problem with the current browser? Also is there a way to browse a Trait say TPureBehavior

My image is based on: sq3.9-7067web07.08.1

Thanks

Nick
Reply | Threaded
Open this post in threaded view
|

Re: Traits

Klaus D. Witzel
Hi Nick,

on Tue, 25 Sep 2007 02:00:50 +0200, you wrote:

>
> Armed with new knowledge of Traits gained from the excellent "Squeak By
> Example" I tried:
>     Smalltalk allClasses select: [:each | each hasTraitComposition]
>
> which gave:
>
> an OrderedCollection(ActionSequence BalloonBezierSimulation BalloonEngine
> BalloonEngineConstants BasicRequestor Behavior BrowserProvider
> ....WorldMenuProvider XMLTokenizer ZipConstants ZipFileConstants)
>
> However browsing to a random class say "ActionSquence", doesn't show any
> evidence of Trait composition. Is this a problem with the current  
> browser?

You're right, (TraitComposition allInstances reject: [:each | each  
isEmpty]) size gives just 17 in my squeak-web image but TraitComposition  
allInstances size reports 325. Could you report your find on  
bugs.squeak.org, this should be investigated if empty TraitComposition  
should really populate the image. Perhaps #traitComposition was used  
unconditional.

> Also is there a way to browse a Trait say TPureBehavior

Just select that name and alt-b opens a browser on TPureBehavior.

/Klaus

> My image is based on: sq3.9-7067web07.08.1
>
> Thanks
>
> Nick


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Traits

Bert Freudenberg
In reply to this post by Nick
On Sep 25, 2007, at 2:00 , Nick Ager wrote:

>
> Armed with new knowledge of Traits gained from the excellent  
> "Squeak By
> Example" I tried:
>     Smalltalk allClasses select: [:each | each hasTraitComposition]
>
> which gave:
>
> an OrderedCollection(ActionSequence BalloonBezierSimulation  
> BalloonEngine
> BalloonEngineConstants BasicRequestor Behavior BrowserProvider
> ....WorldMenuProvider XMLTokenizer ZipConstants ZipFileConstants)
>
> However browsing to a random class say "ActionSquence", doesn't  
> show any
> evidence of Trait composition. Is this a problem with the current  
> browser?

No. #hasTraitComposition only checks if the traitCompositions  
variable is not nil - the composition may still be empty. Which can  
happen quite easily since that variable is lazily initialized by  
sending #traitCompositions.

This appears to be by design, the codebase is scattered with  
#hasTraitComposition checks. But missing only one occurrence where  
#traitCompositions is sent unguarded by #hasTraitComposition will get  
the variable populated. And it will never get reset to nil as far as  
I can tell.

- Bert -


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners