<p dir="ltr"><br>
On Sep 30, 2016 09:50, "Nicolas Cellier" <<a href="mailto:nicolas.cellier.aka.nice@gmail.com">nicolas.cellier.aka.nice@gmail.com</a>> wrote:<br>
><br>
><br>
><br>
> 2016-09-30 14:57 GMT+02:00 Jakob Reschke <<a href="mailto:jakob.reschke@student.hpi.de">jakob.reschke@student.hpi.de</a>>:<br>
>><br>
>> Hello,<br>
>><br>
>> Looks good to me as an outline. I have the following comments,<br>
>> questions or doubts:<br>
>><br>
>> 1. Currently, for me it does not feel like "entering" or "leaving" an<br>
>> Environment, as that works with dynamic scoping in a block. So step 8<br>
>> could turn out to be void.<br>
>><br>
>> 2. Since all of this should go into a workspace, not into the browser,<br>
>> what is the shortest applicable snippet of code that, given a source<br>
>> code string and a class, creates a new method in that class?<br>
>><br>
>> 3. I am not sure what will happen if you attempt to create a subclass<br>
>> that has the same name as another imported class. Generally,<br>
>> evaluating Superclass subclass: #Subclass ... a second time will<br>
>> replace the former Subclass by the new Subclass. 'myEnvironment' would<br>
>> have imported Hello from Smalltalk globals, so an "old" Hello is<br>
>> already visible. We have to check that evaluating the subclass<br>
>> expression will not try to update that existing Hello class, but<br>
>> create a new one instead. Here, the "shallow" lookup mechanism would<br>
>> be needed.<br>
>><br>
> Don't import: Smalltalk globals entirely, just from: Smalltalk globals import: #Transcript.<br>
> and #Object too, depending in which environment you'll evaluate the message for creating the class...<br>
> <br>
>><br>
>> Once I have figured out 2. I will try out and check 3. ;-)<br>
>><br>
>> Kind regards,<br>
>> Jakob<br>
>><br>
><br>
> Here is a snippet that works, but is not especially short.<br>
><br>
> | createHelloClass createHelloMethod english spanish |<br>
><br>
> "Straight but verbose code to create a Hello class and compile a say method.<br>
> There's one trick: Environment current, otherwise Compiler would evaluate in nil class environment, not good"<br>
> createHelloClass := [Object subclass: #Hello<br>
> instanceVariableNames: '' <br>
> classVariableNames: '' <br>
> poolDictionaries: ''<br>
> category: 'Test'].<br>
> createHelloMethod := [:greeting |<br>
> | methodSource sourceCode |<br>
> methodSource := 'say Transcript cr; show: ' , greeting printString.<br>
> sourceCode := 'Hello class compile: ' , methodSource printString , ' classified: ' , 'test' printString.<br>
> Compiler evaluate: sourceCode environment: Environment current].<br>
><br>
> "Create the english and spanish environments"<br>
> english := Smalltalk globals.<br>
> spanish := Environment withName: 'Spanish'.<br>
> spanish importSelf.<br>
> spanish from: english import: #Transcript.<br>
><br>
> "Create the class and compile the method in each environment:"<br>
><br>
> [createHelloClass value.<br>
> createHelloMethod value: 'Hello world'] on: CurrentEnvironment do: [:exc | exc resume: english].<br>
><br>
> [createHelloClass value.<br>
> createHelloMethod value: 'Buenos dias'] on: CurrentEnvironment do: [:exc | exc resume: spanish].<br>
><br>
> "Greet"<br>
> Compiler evaluate: 'Hello say' environment: english.<br>
> Compiler evaluate: 'Hello say' environment: spanish.<br>
> Compiler evaluate: 'Hello say' environment: english.<br>
><br>
> "Cleanup"<br>
> [Compiler evaluate: 'Hello removeFromSystem' environment: Environment current] on: CurrentEnvironment do: [:exc | exc resume: english].<br>
> [Compiler evaluate: 'Hello removeFromSystem' environment: Environment current] on: CurrentEnvironment do: [:exc | exc resume: spanish].<br>
> <br>
> Yes, a DynamicVariable:<br>
> CurrentEnvironment value: english during: ["load something"].<br>
> would be nicer than:<br>
> ["load something"] on: CurrentEnvironment do: [:exc | exc resume: english].<br>
> Otherwise we coulf fileIn some chunk format stream thru en EnvironmentLoader for: english...</p>
<p dir="ltr">I wrote Control to do pretty much that: give a nice interface through which to create and change delimited dynamic variables (and delimited continuations). I would link to it (it's on SS3) but my phone is a bit limited...</p>
<p dir="ltr">frank</p>
<p dir="ltr">>> 2016-09-30 13:29 GMT+02:00 H. Hirzel <<a href="mailto:hannes.hirzel@gmail.com">hannes.hirzel@gmail.com</a>>:<br>
>> > Starting a new thread, culled from the thread 'What are environments for'.<br>
>> ><br>
>> > There are many more good questions and thoughts in the thread 'What<br>
>> > are environments for' but this thread is just about what the subject<br>
>> > says:<br>
>> ><br>
>> > How to create a 'Hello world' example for environments<br>
>> ><br>
>> > --Hannes<br>
>> ><br>
>> > On 9/29/16, David T. Lewis <<a href="mailto:lewis@mail.msen.com">lewis@mail.msen.com</a>> wrote:<br>
>> >> On Thu, Sep 29, 2016 at 07:51:23AM +0200, H. Hirzel wrote:<br>
>> >>> On 9/29/16, Jakob Reschke <<a href="mailto:jakob.reschke@student.hpi.de">jakob.reschke@student.hpi.de</a>> wrote:<br>
>> >>> > Hi Nicolas,<br>
>> >>> ><br>
>> >>> > First, thank you for answering me in the other thread.<br>
>> >>> ><br>
>> >>> > 2016-09-28 23:02 GMT+02:00 Nicolas Cellier<br>
>> >>> > <<a href="mailto:nicolas.cellier.aka.nice@gmail.com">nicolas.cellier.aka.nice@gmail.com</a>>:<br>
>> >>> >> Without clear goals or vision, fixing could essentially mean "let<br>
>> >>> >> Environment be transparent", that is let it remain a promise, a<br>
>> >>> >> potential,<br>
>> >>> >> whithout too many side effects... Not exactly YAGNI, just a bit of<br>
>> >>> >> over-engineered nice piece of code that might serve later. OK this<br>
>> >>> >> sounds<br>
>> >>> >> like a mandatory first step.<br>
>> ><br>
>> ><br>
>> >>> > I don't quite get what you mean by transparent, other than fixing it<br>
>> >>> > and enhancing the documentation to shed some light on what it is, why<br>
>> >>> > it is there and how to use it.<br>
>> > ..<br>
>> > ...<br>
>> ><br>
>> >>> Another maybe simple use case could be to have a project specific<br>
>> >>> environment set up when you enter a project<br>
>> >>> (<a href="http://wiki.squeak.org/squeak/1020">http://wiki.squeak.org/squeak/1020</a>).<br>
>> >>><br>
>> >>> We now have very nicely cleaned up Project code in Squeak 5.1<br>
>> >>><br>
>> >>> 1) Subclass MorphicProject --- MyMorphicProject<br>
>> >>> 2) Subclass PasteUpMorph --- MyPasteUpMorph<br>
>> >>> 3) Override #initialize in MyMorphicProject and use MyPasteUpMorph<br>
>> >>> 4) ... some more adaptations ..... to enter a new Environment -- how?<br>
>> >>><br>
>> >><br>
>> >> I like this idea a lot.<br>
>> >><br>
>> >> I would love to see a simple "hello world!" level example of Environments.<br>
>> >> If someone could make an EnvironmentsDemoProject that opens a new project<br>
>> >> with<br>
>> >> something that changes Duck>>speak ==> 'quack' to Duck>>speak ==> 'moo',<br>
>> >> I think it might really help me to understand how to use Environments.<br>
>> >><br>
>> >> Dave<br>
>> ><br>
>> > So let's focus on a 'hello world' example for environments and do it<br>
>> > _slowly_ step by step so that people can catch up with the issues.<br>
>> ><br>
>> ><br>
>> ><br>
>> > Outline of steps of a 'Hello world' environments example<br>
>> > =============================================<br>
>> ><br>
>> > Steps<br>
>> ><br>
>> ><br>
>> > 1. subclass Object with a #Hello class.<br>
>> ><br>
>> > 2. compile a class method #say the method should write 'Hello' to the Transcript<br>
>> ><br>
>> > 3. run<br>
>> > Hello say<br>
>> ><br>
>> > The result should be 'Hello' on the Transcript<br>
>> ><br>
>> ><br>
>> > 4. create a new Environment called "myEnvironment".<br>
>> ><br>
>> > 5. import the Smalltalk environmnet into myEnvironment<br>
>> ><br>
>> > 6. subclass Object with a #Hello class in myEnvironment<br>
>> ><br>
>> > 7. compile a method #say the method should write 'Buenas dias' to the Transcript<br>
>> ><br>
>> > run<br>
>> > Hello say<br>
>> ><br>
>> > Result should be<br>
>> ><br>
>> > 30-Sept-2016<br>
>> ><br>
>> > Starting a new thread, culled from the thread 'What are environments for'.<br>
>> ><br>
>> > There are many more good questions and thoughts in the thread 'What<br>
>> > are environments for' but this thread is just about what the subject<br>
>> > says:<br>
>> ><br>
>> > How to create a 'Hello world' example for environments<br>
>> ><br>
>> > --Hannes<br>
>> ><br>
>> > On 9/29/16, David T. Lewis <<a href="mailto:lewis@mail.msen.com">lewis@mail.msen.com</a>> wrote:<br>
>> >> On Thu, Sep 29, 2016 at 07:51:23AM +0200, H. Hirzel wrote:<br>
>> >>> On 9/29/16, Jakob Reschke <<a href="mailto:jakob.reschke@student.hpi.de">jakob.reschke@student.hpi.de</a>> wrote:<br>
>> >>> > Hi Nicolas,<br>
>> >>> ><br>
>> >>> > First, thank you for answering me in the other thread.<br>
>> >>> ><br>
>> >>> > 2016-09-28 23:02 GMT+02:00 Nicolas Cellier<br>
>> >>> > <<a href="mailto:nicolas.cellier.aka.nice@gmail.com">nicolas.cellier.aka.nice@gmail.com</a>>:<br>
>> >>> >> Without clear goals or vision, fixing could essentially mean "let<br>
>> >>> >> Environment be transparent", that is let it remain a promise, a<br>
>> >>> >> potential,<br>
>> >>> >> whithout too many side effects... Not exactly YAGNI, just a bit of<br>
>> >>> >> over-engineered nice piece of code that might serve later. OK this<br>
>> >>> >> sounds<br>
>> >>> >> like a mandatory first step.<br>
>> ><br>
>> ><br>
>> >>> > I don't quite get what you mean by transparent, other than fixing it<br>
>> >>> > and enhancing the documentation to shed some light on what it is, why<br>
>> >>> > it is there and how to use it.<br>
>> > ..<br>
>> > ...<br>
>> ><br>
>> >>> Another maybe simple use case could be to have a project specific<br>
>> >>> environment set up when you enter a project<br>
>> >>> (<a href="http://wiki.squeak.org/squeak/1020">http://wiki.squeak.org/squeak/1020</a>).<br>
>> >>><br>
>> >>> We now have very nicely cleaned up Project code in Squeak 5.1<br>
>> >>><br>
>> >>> 1) Subclass MorphicProject --- MyMorphicProject<br>
>> >>> 2) Subclass PasteUpMorph --- MyPasteUpMorph<br>
>> >>> 3) Override #initialize in MyMorphicProject and use MyPasteUpMorph<br>
>> >>> 4) ... some more adaptations ..... to enter a new Environment -- how?<br>
>> >>><br>
>> >><br>
>> >> I like this idea a lot.<br>
>> >><br>
>> >> I would love to see a simple "hello world!" level example of Environments.<br>
>> >> If someone could make an EnvironmentsDemoProject that opens a new project<br>
>> >> with<br>
>> >> something that changes Duck>>speak ==> 'quack' to Duck>>speak ==> 'moo',<br>
>> >> I think it might really help me to understand how to use Environments.<br>
>> >><br>
>> >> Dave<br>
>> ><br>
>> > So let's focus on a 'hello world' example for environments and do it<br>
>> > _slowly_ step by step so that people can catch up with the issues.<br>
>> ><br>
>> ><br>
>> ><br>
>> > Outline of steps of a 'Hello world' environments example<br>
>> > =============================================<br>
>> ><br>
>> > Steps<br>
>> ><br>
>> ><br>
>> > 1. subclass Object with a #Hello class.<br>
>> ><br>
>> > 2. compile a class method #say the method should write 'Hello' to the Transcript<br>
>> ><br>
>> > 3. run<br>
>> > Hello say<br>
>> ><br>
>> > The result should be 'Hello' on the Transcript<br>
>> ><br>
>> ><br>
>> > 4. create a new Environment called "myEnvironment".<br>
>> ><br>
>> > 5. import the Smalltalk environmnet into myEnvironment<br>
>> ><br>
>> > 6. subclass Object with a #Hello class in myEnvironment<br>
>> ><br>
>> > 7. compile a method #say the method should write 'Buenas dias' to the Transcript<br>
>> ><br>
>> > run<br>
>> > Hello say<br>
>> ><br>
>> > The result should be 'Buenas dias' on the Transcript<br>
>> ><br>
>> ><br>
>> > 8. Leave environment called 'myEnvironment'<br>
>> ><br>
>> ><br>
>> > 9. run<br>
>> > Hello say<br>
>> ><br>
>> > The result should be this time 'Hello' on the Transcript<br>
>> ><br>
>> ><br>
>> ><br>
>> > Any comments on these steps?<br>
>> ><br>
>><br>
><br>
><br>
><br>
></p>