[squeak-dev] List of all global variables? (Environments?)

Bert Freudenberg bert at freudenbergs.de
Tue Apr 4 14:02:48 UTC 2017


On Tue, Apr 4, 2017 at 3:47 PM, Eliot Miranda <eliot.miranda at gmail.com>
wrote:

> Hi Levente,
>
> > On Apr 3, 2017, at 11:14 AM, Levente Uzonyi <leves at caesar.elte.hu>
> wrote:
> >
> >  The correct solution is:
> >
> > Array streamContents: [ :stream |
> >    Smalltalk globals associationsDo: [ :binding |
> >        binding class == Global ifTrue: [ stream nextPut: binding ] ] ].
>

Or shorter

    Smalltalk globals declarations select: #canAssign

maybe? Unlike class bindings, global vars are writable.


> Why not
>
> Array streamContents: [ :stream |
>    Smalltalk globals associationsDo: [ :binding |
>        (binding class == Global
>        and: [ binding value isBehavior
>        and: [ binding key == binding value name ] ]) ifTrue:
>             [ stream nextPut: binding ] ] ].
>

Because we want to know the global *variables*, that is everything *but*
the class bindings. So we look for instances of Global, not ClassBinding,
no matter the value.

> The role of declarations and bindings is still not clear in Environments,
> therefore, as I wrote it before, unrelated to tool support, I still
> consider Environments to be incomplete.
>

I thought 'declarations' are the things owned by this environment
(excluding imports), whereas 'bindings' are the things visible in this
environment (including imports).

- Bert -
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20170404/d36a9e1d/attachment.html>


More information about the Squeak-dev mailing list