<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2016-09-28 17:51 GMT+02:00 Nicolas Cellier <span dir="ltr">&lt;<a href="mailto:nicolas.cellier.aka.nice@gmail.com" target="_blank">nicolas.cellier.aka.nice@gmail.com</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"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="gmail-">2016-09-28 11:17 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><wbr>:<br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">Let me repeat my question which might have gone unnoticed in my<br>
previous wall of text:<br>
<br>
Why doesn&#39;t the global environment (Smalltalk globals) export anything<br>
by default? Is there a reason at all, or was it simply forgotten at<br>
some point (because &quot;nobody uses Environments&quot; anyway)?<br>
<br></blockquote><div><br></div></span><div>It&#39;s a bug.<br></div><div>Currently, the Environment SUnit tests only work because of strange name scope resolution:<br></div><div>we use the environment of superclass in that resolution with no good reason.<br>Since ProtoObject/Object are in the class hierarchy, we have undue access to Smalltalk globals.<br><br></div><div>See below some changes rotting for too long in squeak inbox.<br><br></div><div>IMO, we should evaluate &#39;Smalltalk exportSelf&#39; in environment package post actions, then apply the fix below.<br></div><div><br><div> <br></div></div></div></div></div></blockquote><div><br></div><div>Also don&#39;t forget that each environment pretends that Smalltalk globals are pointing to itself (see  Environment&gt;&gt;<wbr>initializeWithName:), creating some kind of sand-boxing.<br></div><div>It&#39;s nice.<br><br></div><div>But Smalltalk is now ambiguous ;)<br>And not so nice at the moment, because some names are misleading now.<br>Smalltalk globals are not really 
globals (the variable scope meaning). Or they are globals in their sandbox...<br>And each Smalltalk is an instance of SmalltalkImage.<br>Once upon a
 time SmalltalkImage current was meant for universal access to state of object memory (image
 as a snapshot) but now what are these &quot;images&quot;?<br>It looks like 
unfinished job, with very short term goal (maximizing portability).<br></div><div>I don&#39;t know what are the next steps for constructing something solid and consistent. We&#39;re not yet there.<br></div><div><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 dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div><div>----------------------------<br></div></div><br><br><a href="http://source.squeak.org/inbox/Kernel-nice.798.diff" target="_blank">http://source.squeak.org/inbox<wbr>/Kernel-nice.798.diff</a><br></div><div> <br><div></div><div>----------------------------<br></div><br>Name: Kernel-nice.798<br>Author: nice<br>Time: 30 July 2013, 10:34:15.34 pm<br>UUID: e02ae597-3f6d-40b9-9468-bf0141<wbr>6db6de<br>Ancestors: Kernel-nice.797<br><br>Better fix for <a href="http://bugs.squeak.org/view.php?id=1554" target="_blank">http://bugs.squeak.org/view.ph<wbr>p?id=1554</a><br>A class variable defined in a superclass should take precedence over a global variable.<br><br>First look in local class variables.<br>Then look in local sharedPools (a local sharedPool will shadow a super class variable, that sounds fair).<br>Then look in superclass pools.<br>When superclass chain is exhausted, look in the Environment that were provided as parameter.<br><br>Note
 that this is mostly squeak 1.x implementation of #scopeHas:ifTrue: (or 
st-80), except that anEvironment parameter replaces Smalltalk.<br>This way we avoid duplicate lookup of previous workaround.<br>And we never ever look in superclass environment, that&#39;s not necessarily ours.<br><br>This
 currently breaks some EnvironmentTest because inheriting superclass 
environment is a cheap and easy way to  import all Smalltalk (unless you
 are not an Object or ProtoObject of course).<br>The longest and proper 
way would be to properly export some symbols from Smalltalk globals, and
 import them explicitely in the tested environment.<br><br><br></div><div><div class="gmail-h5"><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">
Alternatively: Are there downsides of `Smalltalk globals exportSelf`<br>
other than that you have to do it yourself in current Squeak images?<br>
<div><div><br>
2016-09-23 17:28 GMT+02:00 Jakob Reschke &lt;<a href="mailto:jakob.reschke@student.hpi.de" target="_blank">jakob.reschke@student.hpi.de</a>&gt;<wbr>:<br>
&gt; In the meantime, I figured out that the Smalltalk globals environment<br>
&gt; does not export anything. Hence, nothing can be imported from it by<br>
&gt; default.<br>
&gt;<br>
&gt; Further, I found this post [1] by Frank Shearar, which contains a<br>
&gt; snippet to load a package into an environment (however,<br>
&gt; EnvironmentRequest has been renamed to CurrentEnvironment since then).<br>
&gt; He also proposes `Smalltalk globals exportSelf` there, to let the<br>
&gt; global environment export its contents, which could be one way to<br>
&gt; solve my first problem.<br>
&gt;<br>
&gt; I am unsure how this is intended to be used; what is the reason for<br>
&gt; not letting the global environment export anything by default? After<br>
&gt; all, you have to start somewhere... To attempt an alternative, I<br>
&gt; created a fresh environment for the classes that I want to import<br>
&gt; later under other names like so:<br>
&gt;<br>
&gt;     fsenv := Environment named: #FileSystem.<br>
&gt;     fspackage := PackageOrganizer default packageNamed: &#39;FS&#39; ifAbsent: [].<br>
&gt;     fspackage classes do: [:ea | fsenv bind: ea name to: ea ]<br>
&gt;     fsenv importSelf.<br>
&gt;     fsenv exportSelf.<br>
&gt;     testenv := Environment named: #TestEnv1.<br>
&gt;     testenv importSelf.<br>
&gt;     testenv exportSelf.<br>
&gt;     testenv import: fsenv removingPrefix: &#39;FS&#39;.<br>
&gt;     testenv valueOf: #Filesystem &quot;=&gt; FSFilesystem&quot;<br>
&gt;<br>
&gt; Now I can use testenv valueOf: #Filesystem to retrieve the<br>
&gt; FSFilesystem class, so far so good. I have not used my testenv for<br>
&gt; anything real yet, but it is still missing all the basics such as<br>
&gt; Object or Array. So I doubt it will be of much use, unless I set up<br>
&gt; another environment to import from that contains all the Kernel,<br>
&gt; Collections etc. classes. But this does not feel right, as there<br>
&gt; already is such an environment: Smalltalk globals...<br>
&gt;<br>
&gt; In the post from 2012 for which Chris posted the link, Colin linked an<br>
&gt; image (and luckily, he has not removed it from his webspace since<br>
&gt; then) from which I could grab the browser opening snippet. It is<br>
&gt; simply<br>
&gt;<br>
&gt;     Browser fullOnClass: aClassDefinedInAnotherEnvironm<wbr>ent<br>
&gt;<br>
&gt; ...which in my case gives me a browser for the global environment<br>
&gt; instead, because the &quot;renamed&quot; classes stem from there, of course.<br>
&gt;<br>
&gt; Frank&#39;s post also has another snippet to browse an environment:<br>
&gt;<br>
&gt;     b := Browser new<br>
&gt;       selectEnvironment: anEnvironment;<br>
&gt;       yourself.<br>
&gt;     Browser openBrowserView: (b openEditString: nil) label: b<br>
&gt; defaultBrowserTitle<br>
&gt;<br>
&gt; But it seems like the browser will only show an environment&#39;s own<br>
&gt; contents, not the imported classes. Hence, I do not see anything in my<br>
&gt; environments so far. If my assumption is correct, there is no way to<br>
&gt; see the imported classes under their new names in the browser.<br>
&gt;<br>
&gt; When I try to define a new class using my empty browser on my<br>
&gt; environment, it goes back into Smalltalk globals and puts the class<br>
&gt; there instead. It also does that in Colin&#39;s old image, so I guess<br>
&gt; defining classes in environments is not supported that way.<br>
&gt;<br>
&gt; More elaborate tools are probably required to easily see what is going<br>
&gt; on, without exploring the Environments implementation in parallel.<br>
&gt;<br>
&gt; [1] <a rel="noreferrer" href="http://lists.squeakfoundation.org/pipermail/squeak-dev/2013-December/175519.html" target="_blank">http://lists.squeakfoundation.<wbr>org/pipermail/squeak-dev/2013-<wbr>December/175519.html</a><br>
&gt;<br>
&gt;<br>
&gt; 2016-09-23 11:59 GMT+02:00 Tobias Pape &lt;<a href="mailto:Das.Linux@gmx.de" target="_blank">Das.Linux@gmx.de</a>&gt;:<br>
&gt;&gt; Hi Colin,<br>
&gt;&gt;<br>
&gt;&gt; do you have an idea here?<br>
&gt;&gt;<br>
&gt;&gt; Best regards<br>
&gt;&gt;         -Tobias<br>
&gt;<br>
&gt; 2016-09-16 18:27 GMT+02:00 Chris Cunnington &lt;<a href="mailto:brasspen@gmail.com" target="_blank">brasspen@gmail.com</a>&gt;:<br>
&gt;&gt;&gt;Can I get a system browser for my environment (where saving a method<br>
&gt;&gt;&gt;compiles it with the environment bindings in place)?<br>
&gt;&gt;<br>
&gt;&gt; <a rel="noreferrer" href="http://lists.squeakfoundation.org/pipermail/squeak-dev/2012-June/164605.html" target="_blank">http://lists.squeakfoundation.<wbr>org/pipermail/squeak-dev/2012-<wbr>June/164605.html</a><br>
&gt;&gt;<br>
&gt;&gt; Chris<br>
&gt;<br>
&gt;&gt;<br>
&gt;&gt; On 16.09.2016, at 14:50, Jakob Reschke &lt;<a href="mailto:jakob.reschke@student.hpi.de" target="_blank">jakob.reschke@student.hpi.de</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt;&gt; Hello,<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; I am having a look at Environments, but have not yet figured out, how<br>
&gt;&gt;&gt; to operate them. I would like to create a new environment with an<br>
&gt;&gt;&gt; additional binding for an existing class under another name, and load<br>
&gt;&gt;&gt; a package in that new environment.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; The most of a documentation I have found is <a rel="noreferrer" href="http://wiki.squeak.org/squeak/6220" target="_blank">http://wiki.squeak.org/squeak/<wbr>6220</a><br>
&gt;&gt;&gt; and I have tried the following so far:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; testenv := Environment named: #TestEnv1.<br>
&gt;&gt;&gt; testenv import: Smalltalk globals.<br>
&gt;&gt;&gt; testenv from: Smalltalk globals import: { #String -&gt; #MyString }.<br>
&gt;&gt;&gt; testenv importSelf.<br>
&gt;&gt;&gt; testenv exportSelf.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; However, testenv valueOf: #MyString or testenv valueOf: #String both<br>
&gt;&gt;&gt; return nil instead of the String class. Does it mean that the<br>
&gt;&gt;&gt; from:import: did not work? It seems to only add a policy to my<br>
&gt;&gt;&gt; environment, but no declarations or bindings.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; For evaluating something in context of the environment, I have found<br>
&gt;&gt;&gt; the EnvironmentLoader, but it does not seem to recognize the<br>
&gt;&gt;&gt; additional binding either:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; (EnvironmentLoader for: testenv) evaluate: &#39;MyString&#39;. =&gt; nil<br>
&gt;&gt;&gt; (EnvironmentLoader for: testenv) evaluate: &#39;String&#39;. =&gt; nil<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; (at least the import of the original globals seems to have worked).<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; What steps am I missing?<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Also it is not very convenient to make up strings of code everytime I<br>
&gt;&gt;&gt; want to do something in the other environment, is there a better way?<br>
&gt;&gt;&gt; Can I get a system browser for my environment (where saving a method<br>
&gt;&gt;&gt; compiles it with the environment bindings in place)?<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Best regards,<br>
&gt;&gt;&gt; Jakob<br>
&gt;&gt;&gt;<br>
&gt;&gt;<br>
<br>
</div></div></blockquote></div></div></div><br></div></div>
</blockquote></div><br></div></div>