[squeak-dev] Where does the compiler handle the "local bindings" of workspaces?
karl ramberg
karlramberg at gmail.com
Mon Feb 27 04:43:25 UTC 2023
On Mon, Feb 27, 2023 at 2:09 AM Eduardo Ochs <eduardoochs at gmail.com> wrote:
> Hi list,
>
> first some context:
>
> I was trying to put some blocks of executable notes in something
> like the "Terse Guide to Squeak"... the Terse Guide is implemented
> as a class called TerseGuideHelp, and I was working on a modified
> copy of that class, that I called EdrxGuideHelp... but then I saw
> that the window that shows the content of a topic in a help browser
> treats local variables in a way that is different than the one in
> workspaces - if I run "a := 42" in the window with the contents of a
> topic I get a dialog window whose title is:
>
> Unknown variable: a!
> please correct, or cancel:
>
In HelpBrowser you must declare the variables before using them.
You use vertical lines like this:
| a |
a := 42.
You must select both lines before selecting doIt.
> Now a more basic question. I sort of know where the "local variables"
> of a workspace are stored... if I start with a single workspace and I
> run this on it,
>
> w := Workspace new.
> w buildAndOpen.
>
> and then I run this on the second workspace,
>
> a := 2.
> b := a + 3.
>
> and then go back to the first workspace and "print it" this,
>
> w bindings.
>
> I get:
>
> a Dictionary('a'->2 'b'->5 )
>
HelpBrowser does not implement dynamic binding of variables.
You can right click on a Workspace window and a HelpBrowser window and
inspect the model and see the differences.
Also browse class Workspace and look at access to variable 'bindings'.
[image: image.png]
Best,
Karl
> My first guess was that "do it"s and "print it"s in a workspace use
> a dictionary of bindings, but "do it"s and "print it"s in the
> mini-workspace of a help browser do not. I tried to understand
> "real" workspaces first, and after setting a breakpoint in
>
> TextEditor >> #printIt
>
> and doing lots of single-steppings I arrived at this method,
>
> TextEditor >> #evaluateSelectionAndDo:
>
> that has this:
>
> result := [
> rcvr class evaluatorClass new
> evaluate: self selectionAsStream
> in: ctxt
> to: rcvr
> environment: (model environment ifNil: [Smalltalk globals])
> notifying: self
> ifFail: [self flash. ^ nil]
> logged: true.
> ]
> on: OutOfScopeNotification
> do: [ :ex | ex resume: true].
>
> but when that code calls this method
>
> Compiler >> #evaluate:in:to:environment:notifying:ifFail:logged:
>
> the "rcvr class evaluatorClass new" is simply a "Compiler new", "self
> selectionAsStream" is "a := 2. b := a + 3." as a stream, the ctxt and
> the rcvr are nil, and the environment is just "Smalltalk"... where
> does the dictionary of local bindings enter the story? Am I doing
> something wrong in the debugger?...
>
> Thanks in advance!
> Eduardo Ochs
> http://angg.twu.net/eev-squeak.html
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20230227/b52819a0/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 181058 bytes
Desc: not available
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20230227/b52819a0/attachment-0001.png>
More information about the Squeak-dev
mailing list
|