Fun with Kernel :)
Daniel Vainsencher
danielv at netvision.net.il
Fri Apr 4 17:22:59 UTC 2003
I think what's happening is that a few variants of Browser (browse
recent changes, browse versions) display class comments mixed in with
methods. This is the way they mark such not-quite-methods. I guess the
motivation for putting this code there is that messageset is something
these classes have in common.
I wouldn't pollute the kernel with this knowledge, maybe I'd prefer to
remove firstPrecodeCommentFor: from the kernel (into either some viewer
class or or a class extension).
Actually, thing might work just fine if you simply remove that test -
the next line will react the same way, since it won't be found in the
method dictionary.
Daniel
Stephane Ducasse <ducasse at iam.unibe.ch> wrote:
> hi all
>
> We are have fun with the kernel. here is an example.
>
> Behavior>>firstPrecodeCommentFor: selector
> "If there is a comment in the source code at the given selector that
> preceeds the body of the method, return it here, else return nil"
> "Behavior firstPrecodeCommentFor: #firstPrecodeCommentFor:"
> | parser source tree |
> (MessageSet isPseudoSelector: selector)
> ifTrue: ["Not really a selector"
> ^ nil].
> source _ self
> sourceCodeAt: selector asSymbol
> ifAbsent: [^ nil].
> parser _ self parserClass new.
> tree _ parser
> parse: (ReadStream on: source)
> class: self
> noPattern: false
> context: nil
> notifying: nil
> ifFail: [^ nil].
> ^ (tree comment
> ifNil: [^ nil]) first
>
> This method is linking the core of the kernel with a UI element. But
> What I do not understand is that the symbols in isPseudoSelector:
> are the one used by the browser to distinguish between some of its
> state.
>
> MessageSet>>isPseudoSelector: aSelector
> "Answer whether the given selector is a special marker"
> ^ #(#Comment #Definition #Hierarchy ) includes: aSelector
>
>
>
> Does anybody know when the method firstPrecodeCommentFor: can be
> invoked with
> those symbol???
>
>
> Thanks back to fun and dark side of Squeak
>
>
> Stef and Alex
>
>
> Prof. Dr. Stéphane DUCASSE
> http://www.iam.unibe.ch/~ducasse/
> "if you knew today was your last day on earth, what would you do
> different? ... especially if,
> by doing something different, today might not be your last day on
> earth" Calvin&Hobbes
>
> "The best way to predict the future is to invent it..." Alan Kay.
>
> Open Source Smalltalks: http://www.squeak.org,
> http://www.gnu.org/software/smalltalk/smalltalk.html
> Free books for Universities at
> http://www.esug.org/sponsoring/promotionProgram.html
> Free Online Book at
> http://www.iam.unibe.ch/~ducasse/WebPages/FreeBooks.html
More information about the Squeak-dev
mailing list
|