[squeak-dev] Pragma comprehension assistance, please

Bert Freudenberg bert at freudenbergs.de
Sun May 2 17:42:18 UTC 2010


On 02.05.2010, at 19:32, Chris Cunnington wrote:
> Editor class>>blinkingCursor
> 	<preference: 'Blinking Text Cursor'
> 		category: 'Morphic'
> 		description: 'When true, the text cursor will blink.'
> 		type: #Boolean>
> 	^ BlinkingCursor ifNil: [ true ]
> 
> 1. compile method (i.e. x := Editor class compiledMethodAt: #blinkingCursor) 
> 
> 2. compiled method is sent #pramas message to see if it has any (i.e. x pragmas) 
> 
> 3. it does, so they are executed as a message send before the rest of the method is executed (i.e. ^ BlinkingCursor ifNil: [ true ])
> 
> 4. this changes the context of the system in anticipation of the code in the method
> 
> For example, Editor class #blinkingCursor will set a Preference in the system before the rest of the method executes 
> 
> Problem: How does the System know the receiver the pragma message is supposed to be sent to? Usually, we have a class, we send a message, and return an error if the class doesn't have that selector.
> 
> Here, we only have a method, no specified class. The pragma messages are all unique, they only exist in one class in the system. Perhaps the system identifies the receiver by the uniqueness of the message, and then sends it. 
> 
> Only Preferences is going to have preference:category:description:type:
> 
> Therefore, pragma messages are not polymorphic, because they are only ever defined in a single class (i.e. #primitive: or #primitive:error: in Parser) 
> 
> A package is installed. It doesn't register its needs. The system does so by sending the #pragmas message to compiled methods of the package to be present a list of pragmas. It looks at the returned list, makes a decision, and executes one (or all) of the pragmas as a message to a receiver. Thus, the System context is changed and the package can then proceed. 
> 
> What is it I'm not getting here? I still don't understand how a receiver presents itself to receive the selector in the pragma. Any help would be greatly appreciated. 
> 
> Chris 


These are not message sends but only tags. They are not "executed". There is no receiver.

The compiler puts them into the compiled method. Other code retrieves it - e.g. by sending #pragmas.

- Bert -


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20100502/20931cfb/attachment.htm


More information about the Squeak-dev mailing list