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