Nested Environments demo

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Nested Environments demo

Tony Garnock-Jones-5
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.

Reply | Threaded
Open this post in threaded view
|

Re: Nested Environments demo

Christoph Thiede

Very cool implementation, Tony! I admit that I did not watch the entire video, but what I could see from the screenshots looks great. It feels kind of something that has always been missing in Smalltalk for eternities.


How large is your entire patch? Provided it's not huge, I would vote for introducing these changes into the Trunk.


Best,

Christoph


Von: Squeak-dev <[hidden email]> im Auftrag von Tony Garnock-Jones <[hidden email]>
Gesendet: Dienstag, 30. März 2021 14:12:45
An: The general-purpose Squeak developers list
Betreff: [squeak-dev] Nested Environments demo
 
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.



Carpe Squeak!
Reply | Threaded
Open this post in threaded view
|

Re: Nested Environments demo

Jakob Reschke
In reply to this post by Tony Garnock-Jones-5
Hi Tony,

This looks great and like the tool support that Environments have been missing for some time. I had expected that the Namespace concept would spawn more controversial discussion. Anyway, just the availability of the tool would be a welcome addition in my opinion.

As for those bugs, I guess the community needs to have some discussion and agreement about what the expected behavior would be, though Environments does not seem to be the most favorite topic around. From the comprehensibility perspective, I agree with you that it should behave in less surprising ways than it currently does.

Also thank you for the mention, although I'm humbly not sure whether I deserve the naming next to Colin on that matter. ;-)

Kind regards,
Jakob

Am Di., 30. März 2021 um 14:12 Uhr schrieb Tony Garnock-Jones <[hidden email]>:
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.



Reply | Threaded
Open this post in threaded view
|

Re: Nested Environments demo

marcel.taeumel
In reply to this post by Tony Garnock-Jones-5
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 <[hidden email]>:

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.




nested-environments-mt-comments.1.cs (10K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Nested Environments demo

darth-cheney
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 <[hidden email]> 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 <[hidden email]>:

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