<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p>Hi Lauren,</p>
<p><br>
</p>
<p>> <span>but ed got unbound by the time the block was called.</span></p>
<p><span><br>
</span></p>
<p><span>Could you elaborate that further? If I run your example like this</span></p>
<p><span><br>
</span></p>
<p><span></p>
<div>| ed |</div>
<div>ed := nil.</div>
<div>ed := UIManager default</div>
<div>   edit: 'old'</div>
<div>   label: 'label'</div>
<div>   accept: [ :new |</div>
<div>      self inform: new.</div>
<div>      ed delete].</div>
<br>
</span>
<p></p>
<p><span>then it seems to work as expected: enter something in the workspace, accept it,
<span style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">
new text is passed to the block, </span>workspace is closed.</span></p>
<p><span><br>
</span></p>
<p><span>Best,</span></p>
<p><span>Christoph</span></p>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>Von:</b> Squeak-dev <squeak-dev-bounces@lists.squeakfoundation.org> im Auftrag von Lauren P <drurowin@gmail.com><br>
<b>Gesendet:</b> Montag, 9. Januar 2023 17:50:39<br>
<b>An:</b> The general-purpose Squeak developers list<br>
<b>Betreff:</b> [squeak-dev] getting the edit Workspace from UIManager</font>
<div> </div>
</div>
<div>
<div dir="auto">Hey List,
<div dir="auto"><br>
</div>
<div dir="auto">I'm using UIManager>>edit:label:accept: to open a Text for editing and I'd like to close the Workspace when the user accepts the text.</div>
<div dir="auto"><br>
</div>
<div dir="auto">Is there a way to pass the Workspace to the block closure?</div>
<div dir="auto"><br>
</div>
<div dir="auto">I tried</div>
<div dir="auto"><br>
</div>
<div dir="auto">| ed |</div>
<div dir="auto">ed := UIManager default</div>
<div dir="auto">   edit: o</div>
<div dir="auto">   label: l</div>
<div dir="auto">   accept: [ :new |</div>
<div dir="auto">      . . .</div>
<div dir="auto">      ed delete]</div>
<div dir="auto"><br>
</div>
<div dir="auto">but ed got unbound by the time the block was called.  I was kinda expecting Smalltalk to have lexical extent for block closures, not dynamic extent.¹</div>
<div dir="auto"><br>
</div>
<div dir="auto">I know I can use a Y-combinator to add it to a block variable², but I was wondering if there's something way more Smalltalk and less I-Learned-To-Program-With-Assembler.  I'm sure it's something obvious, but there's just so much to Morphic. 
 It's nice to know I can, but it seems like a bug that I would have to.</div>
<div dir="auto"><br>
</div>
<div dir="auto">Thanks,</div>
<div dir="auto">Lauren</div>
<div dir="auto"><br>
</div>
<div dir="auto">1.  I was studying Context to see how it worked and saw the temp stack gets dropped on return, but had a hard time studying its behavior with block closures and multithreading.</div>
<div dir="auto"><br>
</div>
<div dir="auto">2.  While I was examining the workings of the call stack I figured out how to bind block-local variables from outside their lexical scope.  Mostly to get a better understanding of how it worked.</div>
</div>
</div>
</body>
</html>