On 21 December 2010 23:21, Charles Monteiro <charles@nycsmalltalk.org> wrote:
the first I heard of traits was indeed I believe from a paper by Stef's group if I recall correctly. So that's exactly what I mean.
Nested classes are an organizational and a "structural" construct.
A nested class is defined from within an outer class. They are used when a class is only likely to be instantiated (used) from within another class. For example (just an example) , when you instantiate aBody you would want to instantiate two legs but two legs outside the context of a body may not make sense.
So that seems of some value.
Frankly, nested classes/namespaces is userful to limit the scope of names.
From organizational/structural point of view it not so valuable. Because there is enough ways in smalltalk how to organize your model nicely without using extra dimension(s), such as nested classes.
You can also used it to simply group classes i.e. an outer class Drawing, may specify inner classes Line, Circle, Rectangle etc. To instantiate an inner class you need special access syntax in Ruby you would do something like this:
aCircle = Drawing::Circle.new
ok, that's alright if I'm using nested classes to group.
but you can also do this:
aLeg = Body::Leg.new
you can just do: Body Leg new. and in Body>>#Leg answer any class you want to play role as 'Leg'. Or you missing double colons in the middle? :)
but wait I thought you it only made sense to instantiate a Leg from within the context of a body.
Anyhow, I sort of have mixed feelings about it i.e. if they are worth the extra overhead. Not to mention that Smalltalk's IDE's are not setup to handle them. File based IDE's of course don't care, they just care about the source representation.
This 'nested classes' to me look like nested namespace(s), and nothing more. I'd rather introduce namespaces in smalltalk rather than nested classes. But while having a long background of languages which having namespaces, i could not say that i miss them in smalltalk too much. I can group classes using categories, and that is enough from human perception perspective. Limiting the visibility scope and playing all that 'public/private' games - this is an overengineering. My 2c -- Best regards, Igor Stasenko AKA sig.