[Cuis-dev] Questions about MessageNode macro transformation

Andres Valloud ten at smallinteger.com
Sun Jul 14 22:06:07 PDT 2019


Note that transformation loses the original intent of ifNil:ifNotNil:. 
For instance,

	4 == nil ifTrue: [5]

evaluates to nil, but

	4 ifNil: [5]

evaluates to 4.  That's because the ifNil: messages were meant to 
substitute default values when none were present, rather than being used 
as control structures.

On 7/14/19 15:07, Fernando Gasperi Jabalera via Cuis-dev wrote:
> Hi there,
> 
> I'm was trying to understand why code like:
> 
> a ifNil: [0] ifNotNil: [1]
> 
> when parsed got a corresponding MessageNode with an #ifTrue:ifFalse 
> selector and a receiver of the form a == nil. Following the trail lead 
> me to the macro transformations in the MessageNode class. It seems to me 
> that several messages (some loops, boolean operations like and and most 
> of the if messages) are transformed to a special or canonical form, when 
> some conditions on the number of arguments of the blocks for example are 
> satisfied, so that they can be inlined and therefore run faster. Is that 
> correct? Could someone explain a little bit about why it is this way and 
> which cases are chosen to be inlined?
> 
> Best,
> Fernando.
> 


More information about the Cuis-dev mailing list