[squeak-dev] Environment names and Smalltalk globals printString

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Wed Mar 13 23:02:03 UTC 2013


Hello Colin,

For a few versions, Smalltalk is no more a SystemDictionary but rather
a handle to the System (a so called SmalltalkImage).
Thus the SystemDictionary soleInstance does not directly refers to
itself anymore.
Instead, Smalltalk globals refers to itself thru this indirection.
We have chosen to reflect this indirection thru printString:
    Smalltalk globals printString = 'Smalltalk globals'

With Environment, things are getting more complex, we don't have a
single SystemDictionary anymore.
it seems we're taking a step back:

Smalltalk globals is now an Environment.
    Smalltalk globals class == Environment -> true.

This environment is currently named 'Smalltalk' (via EnvironmentInfo)
and thus print it's name
    Smalltalk globals printString = 'Smalltalk' -> true.

But bindingOf: #Smalltalk is still a different thing:
    Smalltalk globals == Smalltalk -> false.
    Smalltalk class == SmalltalkImage -> true.

I think that this is currently misleading and I would prefer to
restore Smalltalk globals printString = 'Smalltalk globals',
It could be as simple as changing the name in corresponding EnvironmentInfo.

One funny thing is that every named Environment currently creates a
new SmalltalkImage and installs itself in its globals.
So each Environment points to itself indirectly thru

    env := Environment named: 'Foo'.
    (Compiler evaluate: 'Smalltalk globals' environment: env) == env -> true.

So each environment could print 'Smalltalk globals' currently ;)
But maybe some environments might want to directly refer to themselves
like this:

    env := Environment named: 'Bar'.
    env beSelfReflecting.
    (Compiler evaluate: 'Bar' environment: env) == env -> true.

And maybe not all Environment have to be self-reflecting, or refer to
the system (SmalltalkImage) - I'm thinking of sand-boxing here.

Last point, environments names are unique, so they could print:

    env := Environment named: 'Foo'.
    env name = '(Environment named: ''Foo'')'.

What are your plans about this, environments names and self-reflection?

Nicolas


More information about the Squeak-dev mailing list