<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<div id="divtagdefaultwrapper" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;" dir="ltr">
<p>Hi Stef,</p>
<p><br>
</p>
<p>good question. <span style="font-size: 12pt;">You can get the argument names via aBlock</span><span style="font-size: 12pt;"> decompile </span><span style="font-size: 12pt;">arguments, and if you also care about the temp names, you can append aBlock decompile </span><span style="font-size: 12pt;">temporaries</span><span style="font-size: 12pt;">.
 But you probably knew that already :)</span></p>
<p><br>
</p>
<p>If you have the possibility to invoke the block, you could also try something like:</p>
<p><br>
</p>
</div>
<blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;">
<div style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;" dir="ltr">
<p></p>
<div></div>
<div>| y |</div>
<div>y := 10.</div>
<div>([:x | y + x. thisContext] value: 42) tempsAndValues</div>
<div></div>
<p></p>
</div>
</blockquote>
<div style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;" dir="ltr">
<p><br>
</p>
<p>If you cannot invoke the block, here would an even more hacky alternative:</p>
<p><br>
</p>
</div>
<blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;">
<div style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;" dir="ltr">
<p></p>
<div>| y |</div>
<div>y := 10.</div>
<div>aBlock := [:x | y + x].</div>
<div>(aBlock simulateValueWithArguments: (Array new: aBlock numArgs) caller: aBlock outerContext) tempsAndValues</div>
<p></p>
</div>
</blockquote>
<div style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;" dir="ltr">
<br>
</div>
<div style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;" dir="ltr">
<div id="Signature">
<div id="divtagdefaultwrapper" dir="ltr" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;">
<div name="divtagdefaultwrapper" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:; margin:0">
<div><font size="2" color="#808080"></font></div>
</div>
</div>
</div>
But I agree that these are no nice solutions at all. I suppose the point is that in contrast to literal bindings, temporary variables are never actually stored as bindings in the block method. For what purpose do you need the bindings?</div>
<div style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;" dir="ltr">
<br>
</div>
<div style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;" dir="ltr">
Best,</div>
<div style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;" dir="ltr">
Christoph<br>
<br>
<div style="color: rgb(0, 0, 0);">
<div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>Von:</b> Squeak-dev <squeak-dev-bounces@lists.squeakfoundation.org> im Auftrag von Stéphane Rollandin <lecteur@zogotounga.net><br>
<b>Gesendet:</b> Sonntag, 19. April 2020 18:18 Uhr<br>
<b>An:</b> liste [Squeak-dev]<br>
<b>Betreff:</b> [squeak-dev] Accessing temp variables bindings in a BlockClosure</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt;">
<div class="PlainText">Hello,<br>
<br>
Is there a way to map the temp variables stored in a BlockClosure with <br>
their names as they appear in the decompileString?<br>
<br>
For example we have:<br>
<br>
        | y |<br>
        y := 10.<br>
        [:x | y + x] basicAt: 1         "returns 10"<br>
<br>
and<br>
<br>
        | y |<br>
        y := 10.<br>
        [:x | y + x] decompileString    "returns '[:x | y + x]'"<br>
<br>
<br>
What I would like is something like<br>
<br>
        | y |<br>
        y := 10.<br>
        [:x | y + x] tempBindingAt: 1    "would return #y -> 10"<br>
<br>
<br>
Stef<br>
<br>
</div>
</span></font></div>
</div>
</div>
</body>
</html>