[squeak-dev] The Inbox: Kernel-eem.1285.mcz

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Thu Dec 12 10:27:21 UTC 2019


Hi Marcel, of course you already know all this :)
a message is composed of a receiver, a selector and arguments.
a (Compiled)Method holds the instructions to be executed in response to a
message.
The methods are stored by object class (and superclasses...) in
methodDictionary.
In response to a message, the appropriate method is selected by the
receiver by looking up for the message selector in methodDictionary.
The instructions consist mostly of pushing/popping objects between the
stack and object slots or method args/temps, and sending messages.

What Eliot is saying is simply that we should call a spade a spade.
So one could expect (self sendMessage: aMessage), (self sendSelector:
aSelector), but not (self sendMessage: aSelector) nor (self sendSelector:
aMessage).

Le jeu. 12 déc. 2019 à 09:10, Marcel Taeumel <marcel.taeumel at hpi.de> a
écrit :

> Hi Eliot,
>
> how would you define selector, message, (message) send, and method? It
> seems like a "message" is a very high-level concept. Selectors and methods
> seem to be more on the implementation side and thus the right names to use
> for such reflection over compiled code.
>
> Project >> #addDeferredUIMessage:
> CompiledCode >> #abstractBytecodeMessageAt:
> SystemNavigation >> #allSentMessages
> ...
>
> Best,
> Marcel
>
> Am 11.12.2019 20:50:30 schrieb commits at source.squeak.org <
> commits at source.squeak.org>:
> A new version of Kernel was added to project The Inbox:
> http://source.squeak.org/inbox/Kernel-eem.1285.mcz
>
> ==================== Summary ====================
>
> Name: Kernel-eem.1285
> Author: eem
> Time: 11 December 2019, 11:50:19.928718 am
> UUID: 3dce70bd-9166-47fe-a86f-22456db9845a
> Ancestors: Kernel-mt.1284
>
> Commit my own take on sendsSelector: vs sendsMessage:, and selectorsDo: vs
> messagesDo:. IMNERHO sendsMessage: messagesDo: are *wrong*!! :-) c.f.
> Behavior>>selectorsDo:
>
> =============== Diff against Kernel-mt.1284 ===============
>
> Item was changed:
> ----- Method: CompiledCode>>messagesDo: (in category 'scanning') -----
> messagesDo: workBlock
> + "Evaluate aBlock with all the message selectors sent by me. Duplicate
> seletors are possible."
> - "Evaluate aBlock with all the message selectors sent by me. Duplicate
> sends possible."
>
> + "If anything should be deprecated it is messagesDo:; it can be an
> extension in AST/Refactoring.
> + This method enumerates over selectors, not messages. c.f.
> Behavior>>selectorsDo: etc"
> + ^self selectorsDo: workBlock!
> - | scanner selector |
> - self isQuick ifTrue: [^ self].
> -
> - self codeLiteralsDo: [:compiledCode |
> - scanner := InstructionStream on: compiledCode.
> - scanner scanFor: [ :x |
> - (selector := scanner selectorToSendOrSelf) == scanner
> - ifFalse: [workBlock value: selector].
> - false "keep scanning" ] ].!
>
> Item was added:
> + ----- Method: CompiledCode>>selectorsDo: (in category 'scanning') -----
> + selectorsDo: workBlock
> + "Evaluate aBlock with all the message selectors sent by me. Duplicate
> seletors are possible."
> +
> + self isQuick ifTrue: [^self].
> +
> + self codeLiteralsDo:
> + [:compiledCode | | scanner |
> + (scanner := InstructionStream on: compiledCode) scanFor:
> + [:x| | selector |
> + (selector := scanner selectorToSendOrSelf) ~~ scanner ifTrue:
> + [workBlock value: selector].
> + false "keep scanning"]]!
>
> Item was changed:
> ----- Method: CompiledCode>>sendsMessage: (in category 'testing') -----
> + sendsMessage: aSelector
> + "eem: this should be deprecated. This method does not check if a method
> sends a message;
> + it checks if a method sends a message with a particular selector."
> + self flag: #todo.
> - sendsMessage: aSelector
> -
> self messagesDo: [:selector |
> selector = aSelector ifTrue: [^ true]].
> ^ false!
>
> Item was changed:
> ----- Method: CompiledCode>>sendsSelector: (in category 'testing') -----
> sendsSelector: aSelector
> + "Answer if the receiver sends a message whose selector is aSelector."
>
> + self selectorsDo:
> + [:selector | selector = aSelector ifTrue: [^true]].
> + ^false!
> - self flag: #todo. "mt: Deprecate? AST/Refactoring project needs it..."
> - ^ self sendsMessage: aSelector!
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20191212/bb5867c0/attachment-0001.html>


More information about the Squeak-dev mailing list