[squeak-dev] Nested Environments demo

Eric Gade eric.gade at gmail.com
Fri Apr 23 17:32:38 UTC 2021


Hi Tony,

This is really cool. I have a question that might have an obvious answer.
If you were to load some code in via Metacello baseline, or even via Squot,
inside one of these environments would the installed packages be scoped as
expected?

On Fri, Apr 23, 2021 at 4:20 AM Marcel Taeumel <marcel.taeumel at hpi.de>
wrote:

> Hi Tony!
>
> Thanks for the demo!
>
> I like the simplicity of your approach and learned things about
> import/export in environments I did not know about.
>
> Please find attached a changeset with some ideas for Environments-tonyg.79
> (INBOX).
>
> (Think I could live with the term "namespace" ... even though "nested
> environment" might be better for newcomers to distinguish other notions of
> namespace in the system such as selectors in classes, temp names in methods
> etc.)
>
> Best,
> Marcel
>
> Am 30.03.2021 14:12:59 schrieb Tony Garnock-Jones <
> tonyg at leastfixedpoint.com>:
> Hi all,
>
> I recorded a little screencast of the EnvironmentBrowser I've been
> playing with:
>
> https://www.youtube.com/watch?v=1UOyca5-72Y
>
> it's ~11 minutes long if you watch it at 1:1. In the description of the
> video is the outline that I was following as I recorded the talk.
>
> I'll paste it below as well.
>
> Cheers,
> Tony
>
> -=-=-=-=-
>
> [Here's the outline I was following as I recorded this talk.]
>
> Hi everyone.
>
> I'm Tony Garnock-Jones, it's March 30th 2021, and I'm going to walk
> through the experimentation I've been doing on nested Namespaces in
> Squeak Smalltalk.
>
> This work builds on Squeak's Environments, which I think are originally
> due to Colin Putney with some recent work by Jakob Reschke.
>
> I've made some small additions to Environment, and a little subclass
> called Namespace, which allows one to expose Environments via ordinary
> variable reference, if one so chooses. It doesn't change anything about
> how Environments work otherwise, so existing uses should remain unchanged.
>
> I've also added a variant of Browser that shows these accessible
> Environments in a hierarchy, and allows you to manage their imports and
> exports. Here it is.
>
> [Open an EnvironmentBrowser]
> [Navigate to EnvironmentBrowser]
>
> The tool is called EnvironmentBrowser, and it's a very thin veneer over
> the existing underlying Environment machinery.
>
> You can see that compared to the default browser, it has a couple of
> extra panels.
>
> This one [on the left] is a tree of environments. The idea is to take
> Environment's Instances as "well-known" roots for this tree:
>
> Environment wellKnownInstances
>
> Smalltalk is already in there, and at the moment there are no others.
>
> From the roots, we recursively scan each environment for globals that
> are also Environments. This scan is a part of Environment itself:
>
> [Navigate to Environment's namespaceTreeDo: method]
>
> This other panel [on the left, just below the tree of environments]
> shows the imports and exports of this environment.
>
> Here you can see that the default environment, Smalltalk, imports all
> its own bindings, so they're visible to its own classes, and exports all
> its bindings to other Environments that import from Smalltalk.
>
> [Create namespace NS1]
> [Create class String, extends Object, inst var length, category Demo]
> [Create accessors]
>
> printOn: aStream
> aStream nextPutAll: 'I am a ball of wool ', length, ' metres long'
>
> [class side]
> new: size
> ^ self new length: size
> [Proceed on the warning]
>
> [Open workspace in Smalltalk]
> String new: 3
>
> [Open workspace in NS1]
> String new: 3
>
> [Rename NS1 to Fabric]
> [Create namespace NS2]
> [Import Fabric with prefix Fabric]
>
> [Open workspace in NS2]
> String new: 3
> FabricString new: 3
> "Oh! It didn't work! We didn't export it from Fabric."
>
> [Export all from Fabric]
> [Try again - still doesn't work]
> [Redo the import]
> [Try again - works now!]
>
> There are still some issues with, I think, Environments themselves
> propagating changes to each other.
>
> Fabric String new: 3
>
> [Unlink Fabric]
>
> Now we see:
>
> String new: 3
> FabricString new: 3
> Fabric String new: 3 "error on this, Fabric is missing"
>
> [Remove the policy importing Fabric to NS2]
>
> Didn't remove it. Still some bugs.
>
>
>

-- 
Eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20210423/0964e6f9/attachment.html>


More information about the Squeak-dev mailing list