Stefan Monnier writes:
>> This [ ... ] is not a block closure and the "extend" is more like a >> keyword to indicate this special construct. > > "like"? Is it a reserved keyword? Does that mean you can't define > a method called `extend`? You can. However, under this circumstance (very top level) the parser does treat it differently. > > What about the case of "C1 :subclass C2 [...]", is "subclass:" also > a reserved keyword? Does it also prevent using method called > `:subclass`? subclass: is a method call. However, under this circumstance (very top level) the parser is also recognizing the special construct as the body of the class. So in gst3 syntax to protect against these traps, if you do want to have loose statements on the top level you will need to wrap them in a Eval [ ... ] block; which is again a special construct only valid at the top level. > > What about uses of `extend` or `subclass:` elsewhere than at top-level? Then they lose the special treatment. > > Also within such a "set of methods", I see two different method > definitions: > > <method-selector> [<method-body>] > > and > > <class> class >> <method-selector> [<method-body>] > > what happens if <class> is another class than the one for which this > block is defining methods? Theoretically you can; however I think it is not encouraged. > > why do we need both the `class` and the `>>` keywords to define those > class methods? Theoretically you can even write: <class> >> <method-selector> [<method-body>] where <class> is a different class. However it is also not encouraged for obvious reason. The >> seperates the owner of this method and the method itself. Without it it looks really awkward. The outer block in extend or subclass: only gives default owner of methods. > > Are there other possible valid elements than those two? Other than what have been menthoned, no. Actually you don't strictly need the second form if you put all class methods in a: <class> class extend [ ... ] block. There is no special priviledge for method or class method defined in the original subclass: block. > > Where is this documented (other than by showing examples)? > I was wondering the same :) _______________________________________________ help-smalltalk mailing list [email protected] https://lists.gnu.org/mailman/listinfo/help-smalltalk
