Hello,
Looks good to me as an outline. I have the following comments, questions or doubts:
1. Currently, for me it does not feel like "entering" or "leaving" an Environment, as that works with dynamic scoping in a block. So step 8 could turn out to be void.
2. Since all of this should go into a workspace, not into the browser, what is the shortest applicable snippet of code that, given a source code string and a class, creates a new method in that class?
3. I am not sure what will happen if you attempt to create a subclass that has the same name as another imported class. Generally, evaluating Superclass subclass: #Subclass ... a second time will replace the former Subclass by the new Subclass. 'myEnvironment' would have imported Hello from Smalltalk globals, so an "old" Hello is already visible. We have to check that evaluating the subclass expression will not try to update that existing Hello class, but create a new one instead. Here, the "shallow" lookup mechanism would be needed.
Once I have figured out 2. I will try out and check 3. ;-)
Kind regards, Jakob
2016-09-30 13:29 GMT+02:00 H. Hirzel hannes.hirzel@gmail.com:
Starting a new thread, culled from the thread 'What are environments for'.
There are many more good questions and thoughts in the thread 'What are environments for' but this thread is just about what the subject says:
How to create a 'Hello world' example for environments
--Hannes
On 9/29/16, David T. Lewis lewis@mail.msen.com wrote:
On Thu, Sep 29, 2016 at 07:51:23AM +0200, H. Hirzel wrote:
On 9/29/16, Jakob Reschke jakob.reschke@student.hpi.de wrote:
Hi Nicolas,
First, thank you for answering me in the other thread.
2016-09-28 23:02 GMT+02:00 Nicolas Cellier nicolas.cellier.aka.nice@gmail.com:
Without clear goals or vision, fixing could essentially mean "let Environment be transparent", that is let it remain a promise, a potential, whithout too many side effects... Not exactly YAGNI, just a bit of over-engineered nice piece of code that might serve later. OK this sounds like a mandatory first step.
I don't quite get what you mean by transparent, other than fixing it and enhancing the documentation to shed some light on what it is, why it is there and how to use it.
.. ...
Another maybe simple use case could be to have a project specific environment set up when you enter a project (http://wiki.squeak.org/squeak/1020).
We now have very nicely cleaned up Project code in Squeak 5.1
- Subclass MorphicProject --- MyMorphicProject
- Subclass PasteUpMorph --- MyPasteUpMorph
- Override #initialize in MyMorphicProject and use MyPasteUpMorph
- ... some more adaptations ..... to enter a new Environment -- how?
I like this idea a lot.
I would love to see a simple "hello world!" level example of Environments. If someone could make an EnvironmentsDemoProject that opens a new project with something that changes Duck>>speak ==> 'quack' to Duck>>speak ==> 'moo', I think it might really help me to understand how to use Environments.
Dave
So let's focus on a 'hello world' example for environments and do it _slowly_ step by step so that people can catch up with the issues.
Outline of steps of a 'Hello world' environments example
Steps
subclass Object with a #Hello class.
compile a class method #say the method should write 'Hello' to the Transcript
run Hello say
The result should be 'Hello' on the Transcript
create a new Environment called "myEnvironment".
import the Smalltalk environmnet into myEnvironment
subclass Object with a #Hello class in myEnvironment
compile a method #say the method should write 'Buenas dias' to the Transcript
run Hello say
Result should be
30-Sept-2016
Starting a new thread, culled from the thread 'What are environments for'.
There are many more good questions and thoughts in the thread 'What are environments for' but this thread is just about what the subject says:
How to create a 'Hello world' example for environments
--Hannes
On 9/29/16, David T. Lewis lewis@mail.msen.com wrote:
On Thu, Sep 29, 2016 at 07:51:23AM +0200, H. Hirzel wrote:
On 9/29/16, Jakob Reschke jakob.reschke@student.hpi.de wrote:
Hi Nicolas,
First, thank you for answering me in the other thread.
2016-09-28 23:02 GMT+02:00 Nicolas Cellier nicolas.cellier.aka.nice@gmail.com:
Without clear goals or vision, fixing could essentially mean "let Environment be transparent", that is let it remain a promise, a potential, whithout too many side effects... Not exactly YAGNI, just a bit of over-engineered nice piece of code that might serve later. OK this sounds like a mandatory first step.
I don't quite get what you mean by transparent, other than fixing it and enhancing the documentation to shed some light on what it is, why it is there and how to use it.
.. ...
Another maybe simple use case could be to have a project specific environment set up when you enter a project (http://wiki.squeak.org/squeak/1020).
We now have very nicely cleaned up Project code in Squeak 5.1
- Subclass MorphicProject --- MyMorphicProject
- Subclass PasteUpMorph --- MyPasteUpMorph
- Override #initialize in MyMorphicProject and use MyPasteUpMorph
- ... some more adaptations ..... to enter a new Environment -- how?
I like this idea a lot.
I would love to see a simple "hello world!" level example of Environments. If someone could make an EnvironmentsDemoProject that opens a new project with something that changes Duck>>speak ==> 'quack' to Duck>>speak ==> 'moo', I think it might really help me to understand how to use Environments.
Dave
So let's focus on a 'hello world' example for environments and do it _slowly_ step by step so that people can catch up with the issues.
Outline of steps of a 'Hello world' environments example
Steps
subclass Object with a #Hello class.
compile a class method #say the method should write 'Hello' to the Transcript
run Hello say
The result should be 'Hello' on the Transcript
create a new Environment called "myEnvironment".
import the Smalltalk environmnet into myEnvironment
subclass Object with a #Hello class in myEnvironment
compile a method #say the method should write 'Buenas dias' to the Transcript
run Hello say
The result should be 'Buenas dias' on the Transcript
Leave environment called 'myEnvironment'
run Hello say
The result should be this time 'Hello' on the Transcript
Any comments on these steps?