<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2016-09-30 14:57 GMT+02:00 Jakob Reschke <span dir="ltr"><<a href="mailto:jakob.reschke@student.hpi.de" target="_blank">jakob.reschke@student.hpi.de</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">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></blockquote><div>Don't import: Smalltalk globals entirely, just from: Smalltalk globals import: #Transcript.<br></div><div>and #Object too, depending in which environment you'll evaluate the message for creating the class...<br> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Once I have figured out 2. I will try out and check 3. ;-)<br>
<br>
Kind regards,<br>
Jakob<br>
<div class="gmail-HOEnZb"><div class="gmail-h5"><br></div></div></blockquote><div><br>Here is a snippet that works, but is not especially short.</div><div><br>| createHelloClass createHelloMethod english spanish |<br><br></div><div>"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></div><div>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].</div><div><br></div><div>"Create the english and spanish environments"<br></div><div>english := Smalltalk globals.<br>spanish := Environment withName: 'Spanish'.<br>spanish importSelf.<br>spanish from: english import: #Transcript.<br><br></div><div>"Create the class and compile the method in each environment:"<br><br></div><div>[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></div><div>"Greet"<br></div><div>Compiler evaluate: 'Hello say' environment: english.<br>Compiler evaluate: 'Hello say' environment: spanish.<br>Compiler evaluate: 'Hello say' environment: english.<br><br></div><div>"Cleanup"<br></div><div>[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><div>Yes, a DynamicVariable:<br></div><div> CurrentEnvironment value: english during: ["load something"].<br></div><div>would be nicer than:<br> ["load something"] on: CurrentEnvironment do: [:exc | exc resume: english].</div>Otherwise we coulf fileIn some chunk format stream thru en EnvironmentLoader for: english...<br><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail-HOEnZb"><div class="gmail-h5">
<br>
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@<wbr>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" rel="noreferrer" target="_blank">http://wiki.squeak.org/<wbr>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>
> ==============================<wbr>===============<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@<wbr>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" rel="noreferrer" target="_blank">http://wiki.squeak.org/<wbr>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>
> ==============================<wbr>===============<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>
</div></div></blockquote></div><br></div></div>