[squeak-dev] Where does the compiler handle the "local bindings" of workspaces?

Eduardo Ochs eduardoochs at gmail.com
Mon Feb 27 01:08:58 UTC 2023


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:

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 )

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/20230226/e71f4974/attachment.html>


More information about the Squeak-dev mailing list