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