[squeak-dev] Question about inlining | How to access named temps in FullBlockClosure?

Marcel Taeumel marcel.taeumel at hpi.de
Thu Mar 26 12:15:11 UTC 2020


Hi Eliot, hi all!

I am having issues with the inlining of #to:do: in combination with decompiling a block and accessing the temps.

Here is a piece of code that works as expected:

| result context |
result := OrderedCollection new.

(1 to: 5) do: [:each |
result add: [:object | object + each]].

context := (result at: 3) outerContext.
context namedTempAt: (context tempNames indexOf: 'each'). " == 3"

HOWEVER, using #to:do: the result changes because code gets inlined:

| result context |
result := OrderedCollection new.

1 to: 5 do: [:each |
result add: [:object | object + each]].

context := (result at: 3) outerContext.
context namedTempAt: (context tempNames indexOf: 'each'). " == 6"

What is my goal here? I want to unpack the block statement and fill in the temps. For all those [:object | object + each] in "result" I want to collect the strings:

-> 'object + 1'
-> 'object + 2'

-> 'object + 3'

-> 'object + 4'

-> 'object + 5'


Is there a way to access the values of temps when the block closures are created this way?

Best,
Marcel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20200326/33cff01b/attachment.html>


More information about the Squeak-dev mailing list