<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">&lt;<a href="mailto:jakob.reschke@student.hpi.de" target="_blank">jakob.reschke@student.hpi.de</a>&gt;</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 &quot;entering&quot; or &quot;leaving&quot; 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. &#39;myEnvironment&#39; would<br>
have imported Hello from Smalltalk globals, so an &quot;old&quot; 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 &quot;shallow&quot; lookup mechanism would<br>
be needed.<br>
<br></blockquote><div>Don&#39;t import: Smalltalk globals entirely, just from: Smalltalk globals import: #Transcript.<br></div><div>and #Object too, depending in which environment you&#39;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>&quot;Straight but verbose code to create a Hello class and compile a say method.<br> There&#39;s one trick: Environment current, otherwise Compiler would evaluate in nil class environment, not good&quot;<br></div><div>createHelloClass := [Object subclass: #Hello<br>            instanceVariableNames: &#39;&#39; <br>            classVariableNames: &#39;&#39; <br>            poolDictionaries: &#39;&#39;<br>            category: &#39;Test&#39;].<br>createHelloMethod := [:greeting |<br>    | methodSource sourceCode |<br>    methodSource := &#39;say Transcript cr; show: &#39; , greeting printString.<br>    sourceCode := &#39;Hello class compile: &#39; , methodSource printString , &#39; classified: &#39; , &#39;test&#39; printString.<br>    Compiler evaluate: sourceCode environment: Environment current].</div><div><br></div><div>&quot;Create the english and spanish environments&quot;<br></div><div>english := Smalltalk globals.<br>spanish := Environment withName: &#39;Spanish&#39;.<br>spanish importSelf.<br>spanish from: english import: #Transcript.<br><br></div><div>&quot;Create the class and compile the method in each environment:&quot;<br><br></div><div>[createHelloClass value.<br>createHelloMethod value: &#39;Hello world&#39;] on: CurrentEnvironment do: [:exc | exc resume: english].<br><br>[createHelloClass value.<br>createHelloMethod value: &#39;Buenos dias&#39;] on: CurrentEnvironment do: [:exc | exc resume: spanish].<br><br></div><div>&quot;Greet&quot;<br></div><div>Compiler evaluate: &#39;Hello say&#39; environment: english.<br>Compiler evaluate: &#39;Hello say&#39; environment: spanish.<br>Compiler evaluate: &#39;Hello say&#39; environment: english.<br><br></div><div>&quot;Cleanup&quot;<br></div><div>[Compiler evaluate: &#39;Hello removeFromSystem&#39; environment: Environment current] on: CurrentEnvironment do: [:exc | exc resume: english].<br>[Compiler evaluate: &#39;Hello removeFromSystem&#39; environment: Environment current] on: CurrentEnvironment do: [:exc | exc resume: spanish].<br> <br><div>Yes, a DynamicVariable:<br></div><div>   CurrentEnvironment value: english during: [&quot;load something&quot;].<br></div><div>would be nicer than:<br>    [&quot;load something&quot;] 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 &lt;<a href="mailto:hannes.hirzel@gmail.com">hannes.hirzel@gmail.com</a>&gt;:<br>
&gt; Starting a new thread, culled from the thread &#39;What are environments for&#39;.<br>
&gt;<br>
&gt; There are many more good questions and thoughts in the  thread &#39;What<br>
&gt; are environments for&#39; but this thread is just about what the subject<br>
&gt; says:<br>
&gt;<br>
&gt; How to create a &#39;Hello world&#39; example for environments<br>
&gt;<br>
&gt; --Hannes<br>
&gt;<br>
&gt; On 9/29/16, David T. Lewis &lt;<a href="mailto:lewis@mail.msen.com">lewis@mail.msen.com</a>&gt; wrote:<br>
&gt;&gt; On Thu, Sep 29, 2016 at 07:51:23AM +0200, H. Hirzel wrote:<br>
&gt;&gt;&gt; On 9/29/16, Jakob Reschke &lt;<a href="mailto:jakob.reschke@student.hpi.de">jakob.reschke@student.hpi.de</a>&gt; wrote:<br>
&gt;&gt;&gt; &gt; Hi Nicolas,<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; First, thank you for answering me in the other thread.<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; 2016-09-28 23:02 GMT+02:00 Nicolas Cellier<br>
&gt;&gt;&gt; &gt; &lt;<a href="mailto:nicolas.cellier.aka.nice@gmail.com">nicolas.cellier.aka.nice@<wbr>gmail.com</a>&gt;:<br>
&gt;&gt;&gt; &gt;&gt; Without clear goals or vision, fixing could essentially mean &quot;let<br>
&gt;&gt;&gt; &gt;&gt; Environment be transparent&quot;, that is let it remain a promise, a<br>
&gt;&gt;&gt; &gt;&gt; potential,<br>
&gt;&gt;&gt; &gt;&gt; whithout too many side effects... Not exactly YAGNI, just a bit of<br>
&gt;&gt;&gt; &gt;&gt; over-engineered nice piece of code that might serve later. OK this<br>
&gt;&gt;&gt; &gt;&gt; sounds<br>
&gt;&gt;&gt; &gt;&gt; like a mandatory first step.<br>
&gt;<br>
&gt;<br>
&gt;&gt;&gt; &gt; I don&#39;t quite get what you mean by transparent, other than fixing it<br>
&gt;&gt;&gt; &gt; and enhancing the documentation to shed some light on what it is, why<br>
&gt;&gt;&gt; &gt; it is there and how to use it.<br>
&gt; ..<br>
&gt; ...<br>
&gt;<br>
&gt;&gt;&gt; Another maybe simple use case could be to have a project specific<br>
&gt;&gt;&gt; environment set up when you enter a project<br>
&gt;&gt;&gt; (<a href="http://wiki.squeak.org/squeak/1020" rel="noreferrer" target="_blank">http://wiki.squeak.org/<wbr>squeak/1020</a>).<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; We now have very nicely cleaned up Project code in Squeak 5.1<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; 1) Subclass MorphicProject --- MyMorphicProject<br>
&gt;&gt;&gt; 2) Subclass PasteUpMorph  --- MyPasteUpMorph<br>
&gt;&gt;&gt; 3) Override #initialize in MyMorphicProject and use MyPasteUpMorph<br>
&gt;&gt;&gt; 4) ... some more adaptations ..... to enter a new Environment -- how?<br>
&gt;&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; I like this idea a lot.<br>
&gt;&gt;<br>
&gt;&gt; I would love to see a simple &quot;hello world!&quot; level example of Environments.<br>
&gt;&gt; If someone could make an EnvironmentsDemoProject that opens a new project<br>
&gt;&gt; with<br>
&gt;&gt; something that changes Duck&gt;&gt;speak ==&gt; &#39;quack&#39; to Duck&gt;&gt;speak ==&gt; &#39;moo&#39;,<br>
&gt;&gt; I think it might really help me to understand how to use Environments.<br>
&gt;&gt;<br>
&gt;&gt; Dave<br>
&gt;<br>
&gt; So let&#39;s focus on a &#39;hello world&#39; example for environments and do it<br>
&gt; _slowly_ step by step so that people can catch up with the issues.<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; Outline of steps of a &#39;Hello world&#39; environments example<br>
&gt; ==============================<wbr>===============<br>
&gt;<br>
&gt; Steps<br>
&gt;<br>
&gt;<br>
&gt; 1. subclass Object with a #Hello class.<br>
&gt;<br>
&gt; 2. compile a class method #say the method should write &#39;Hello&#39; to the Transcript<br>
&gt;<br>
&gt; 3. run<br>
&gt;     Hello say<br>
&gt;<br>
&gt;     The result should be &#39;Hello&#39; on the Transcript<br>
&gt;<br>
&gt;<br>
&gt; 4. create a new Environment called &quot;myEnvironment&quot;.<br>
&gt;<br>
&gt; 5. import the Smalltalk environmnet into myEnvironment<br>
&gt;<br>
&gt; 6. subclass Object with a #Hello class in myEnvironment<br>
&gt;<br>
&gt; 7. compile a method #say the method should write &#39;Buenas dias&#39; to the Transcript<br>
&gt;<br>
&gt;    run<br>
&gt;         Hello say<br>
&gt;<br>
&gt;    Result should be<br>
&gt;<br>
&gt;         30-Sept-2016<br>
&gt;<br>
&gt; Starting a new thread, culled from the thread &#39;What are environments for&#39;.<br>
&gt;<br>
&gt; There are many more good questions and thoughts in the  thread &#39;What<br>
&gt; are environments for&#39; but this thread is just about what the subject<br>
&gt; says:<br>
&gt;<br>
&gt; How to create a &#39;Hello world&#39; example for environments<br>
&gt;<br>
&gt; --Hannes<br>
&gt;<br>
&gt; On 9/29/16, David T. Lewis &lt;<a href="mailto:lewis@mail.msen.com">lewis@mail.msen.com</a>&gt; wrote:<br>
&gt;&gt; On Thu, Sep 29, 2016 at 07:51:23AM +0200, H. Hirzel wrote:<br>
&gt;&gt;&gt; On 9/29/16, Jakob Reschke &lt;<a href="mailto:jakob.reschke@student.hpi.de">jakob.reschke@student.hpi.de</a>&gt; wrote:<br>
&gt;&gt;&gt; &gt; Hi Nicolas,<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; First, thank you for answering me in the other thread.<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; 2016-09-28 23:02 GMT+02:00 Nicolas Cellier<br>
&gt;&gt;&gt; &gt; &lt;<a href="mailto:nicolas.cellier.aka.nice@gmail.com">nicolas.cellier.aka.nice@<wbr>gmail.com</a>&gt;:<br>
&gt;&gt;&gt; &gt;&gt; Without clear goals or vision, fixing could essentially mean &quot;let<br>
&gt;&gt;&gt; &gt;&gt; Environment be transparent&quot;, that is let it remain a promise, a<br>
&gt;&gt;&gt; &gt;&gt; potential,<br>
&gt;&gt;&gt; &gt;&gt; whithout too many side effects... Not exactly YAGNI, just a bit of<br>
&gt;&gt;&gt; &gt;&gt; over-engineered nice piece of code that might serve later. OK this<br>
&gt;&gt;&gt; &gt;&gt; sounds<br>
&gt;&gt;&gt; &gt;&gt; like a mandatory first step.<br>
&gt;<br>
&gt;<br>
&gt;&gt;&gt; &gt; I don&#39;t quite get what you mean by transparent, other than fixing it<br>
&gt;&gt;&gt; &gt; and enhancing the documentation to shed some light on what it is, why<br>
&gt;&gt;&gt; &gt; it is there and how to use it.<br>
&gt; ..<br>
&gt; ...<br>
&gt;<br>
&gt;&gt;&gt; Another maybe simple use case could be to have a project specific<br>
&gt;&gt;&gt; environment set up when you enter a project<br>
&gt;&gt;&gt; (<a href="http://wiki.squeak.org/squeak/1020" rel="noreferrer" target="_blank">http://wiki.squeak.org/<wbr>squeak/1020</a>).<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; We now have very nicely cleaned up Project code in Squeak 5.1<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; 1) Subclass MorphicProject --- MyMorphicProject<br>
&gt;&gt;&gt; 2) Subclass PasteUpMorph  --- MyPasteUpMorph<br>
&gt;&gt;&gt; 3) Override #initialize in MyMorphicProject and use MyPasteUpMorph<br>
&gt;&gt;&gt; 4) ... some more adaptations ..... to enter a new Environment -- how?<br>
&gt;&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; I like this idea a lot.<br>
&gt;&gt;<br>
&gt;&gt; I would love to see a simple &quot;hello world!&quot; level example of Environments.<br>
&gt;&gt; If someone could make an EnvironmentsDemoProject that opens a new project<br>
&gt;&gt; with<br>
&gt;&gt; something that changes Duck&gt;&gt;speak ==&gt; &#39;quack&#39; to Duck&gt;&gt;speak ==&gt; &#39;moo&#39;,<br>
&gt;&gt; I think it might really help me to understand how to use Environments.<br>
&gt;&gt;<br>
&gt;&gt; Dave<br>
&gt;<br>
&gt; So let&#39;s focus on a &#39;hello world&#39; example for environments and do it<br>
&gt; _slowly_ step by step so that people can catch up with the issues.<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; Outline of steps of a &#39;Hello world&#39; environments example<br>
&gt; ==============================<wbr>===============<br>
&gt;<br>
&gt; Steps<br>
&gt;<br>
&gt;<br>
&gt; 1. subclass Object with a #Hello class.<br>
&gt;<br>
&gt; 2. compile a class method #say the method should write &#39;Hello&#39; to the Transcript<br>
&gt;<br>
&gt; 3. run<br>
&gt;     Hello say<br>
&gt;<br>
&gt;     The result should be &#39;Hello&#39; on the Transcript<br>
&gt;<br>
&gt;<br>
&gt; 4. create a new Environment called &quot;myEnvironment&quot;.<br>
&gt;<br>
&gt; 5. import the Smalltalk environmnet into myEnvironment<br>
&gt;<br>
&gt; 6. subclass Object with a #Hello class in myEnvironment<br>
&gt;<br>
&gt; 7. compile a method #say the method should write &#39;Buenas dias&#39; to the Transcript<br>
&gt;<br>
&gt;    run<br>
&gt;         Hello say<br>
&gt;<br>
&gt;     The result should be &#39;Buenas dias&#39; on the Transcript<br>
&gt;<br>
&gt;<br>
&gt; 8. Leave environment called &#39;myEnvironment&#39;<br>
&gt;<br>
&gt;<br>
&gt; 9. run<br>
&gt;     Hello say<br>
&gt;<br>
&gt;     The result should be this time &#39;Hello&#39; on the Transcript<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; Any comments on these steps?<br>
&gt;<br>
<br>
</div></div></blockquote></div><br></div></div>