links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
Notes about Environments September 2016 (A)
Last updated at 3:28 pm UTC on 24 September 2016
Jakob Reschke
Fri, Sep 23, 2016 at 5:28 PM
Reply-To: The general-purpose Squeak developers list
To: The general-purpose Squeak developers list

In the meantime, I figured out that the Smalltalk globals environment
does not export anything. Hence, nothing can be imported from it by

Further, I found this post [1] by Frank Shearar, which contains a
snippet to load a package into an environment (however,
EnvironmentRequest has been renamed to CurrentEnvironment since then).
He also proposes `Smalltalk globals exportSelf` there, to let the
global environment export its contents, which could be one way to
solve my first problem.

I am unsure how this is intended to be used; what is the reason for
not letting the global environment export anything by default? After
all, you have to start somewhere... To attempt an alternative, I
created a fresh environment for the classes that I want to import
later under other names like so:

    fsenv := Environment named: #FileSystem.
    fspackage := PackageOrganizer default packageNamed: 'FS' ifAbsent: [].
    fspackage classes do: [:ea | fsenv bind: ea name to: ea ]
    fsenv importSelf.
    fsenv exportSelf.
    testenv := Environment named: #TestEnv1.
    testenv importSelf.
    testenv exportSelf.
    testenv import: fsenv removingPrefix: 'FS'.
    testenv valueOf: #Filesystem "=> FSFilesystem"

Now I can use testenv valueOf: #Filesystem to retrieve the
FSFilesystem class, so far so good. I have not used my testenv for
anything real yet, but it is still missing all the basics such as
Object or Array. So I doubt it will be of much use, unless I set up
another environment to import from that contains all the Kernel,
Collections etc. classes. But this does not feel right, as there
already is such an environment: Smalltalk globals...

In the post from 2012 for which Chris posted the link, Colin linked an
image (and luckily, he has not removed it from his webspace since
then http://www.wiresong.ca/downloads/Environments.zip) from which I could grab the browser opening snippet. It is

   Browser fullOnClass: aClassDefinedInAnotherEnvironment

...which in my case gives me a browser for the global environment
instead, because the "renamed" classes stem from there, of course.

Frank's post also has another snippet to browse an environment:

    b := Browser new
      selectEnvironment: anEnvironment;
    Browser openBrowserView: (b openEditString: nil) label: b

But it seems like the browser will only show an environment's own
contents, not the imported classes. Hence, I do not see anything in my
environments so far. If my assumption is correct, there is no way to
see the imported classes under their new names in the browser.

When I try to define a new class using my empty browser on my
environment, it goes back into Smalltalk globals and puts the class
there instead. It also does that in Colin's old image, so I guess
defining classes in environments is not supported that way.

More elaborate tools are probably required to easily see what is going
on, without exploring the Environments implementation in parallel.

[1] http://lists.squeakfoundation.org/pipermail/squeak-dev/2013-December/175519.html

Continue reading with
Note about Environments September 2016 (B)