[squeak-dev] getting the edit Workspace from UIManager

Thiede, Christoph Christoph.Thiede at student.hpi.uni-potsdam.de
Mon Jan 9 17:29:23 UTC 2023


Hi Lauren,


> but ed got unbound by the time the block was called.


Could you elaborate that further? If I run your example like this


| ed |
ed := nil.
ed := UIManager default
   edit: 'old'
   label: 'label'
   accept: [ :new |
      self inform: new.
      ed delete].


then it seems to work as expected: enter something in the workspace, accept it, new text is passed to the block, workspace is closed.


Best,

Christoph

________________________________
Von: Squeak-dev <squeak-dev-bounces at lists.squeakfoundation.org> im Auftrag von Lauren P <drurowin at gmail.com>
Gesendet: Montag, 9. Januar 2023 17:50:39
An: The general-purpose Squeak developers list
Betreff: [squeak-dev] getting the edit Workspace from UIManager

Hey List,

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.

Is there a way to pass the Workspace to the block closure?

I tried

| ed |
ed := UIManager default
   edit: o
   label: l
   accept: [ :new |
      . . .
      ed delete]

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.¹

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.

Thanks,
Lauren

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.

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20230109/afc564ee/attachment.html>


More information about the Squeak-dev mailing list