[squeak-dev] List of all global variables? (Environments?)
Levente Uzonyi
leves at caesar.elte.hu
Tue Apr 4 17:04:31 UTC 2017
On Tue, 4 Apr 2017, Eliot Miranda wrote:
>
>
> On Apr 4, 2017, at 7:02 AM, Bert Freudenberg <bert at freudenbergs.de> wrote:
>
> 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.
>
>
> I don't like this. I see writability as orthogonal. I'm sure there's good uses for read-only globals that are not classes. I like the tenseness though. So
> Smalltalk globals declarations reject: #isClassBinding
>
> with
> isClassBinding ^value isBehavior and: [key == value name]
Why not just ^true?
It's a ClassBinding even if it's not initialized properly. And that should
be the Environment's responibility.
>
>
> 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.
>
>
> Forgive me; I missed a not in there. But my point is that the classes in global are in bindings whose keys are == to their name. Everything else is a global variable.
We have separate subclasses: ClassBinding and Global. We should use those.
Levente
>
>
> > 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).
>
>
> Is there a definition in text somewhere? Colin?
>
> - Bert -
>
>
>
More information about the Squeak-dev
mailing list
|