<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Dec 2, 2013 at 2:11 PM, Frank Shearar <span dir="ltr">&lt;<a href="mailto:frank.shearar@gmail.com" target="_blank">frank.shearar@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">On 2 December 2013 20:52, Chris Muller &lt;<a href="mailto:asqueaker@gmail.com">asqueaker@gmail.com</a>&gt; wrote:<br>

&gt; I agree wtih Bert, this is generally useful.  I have demand now.  Maui<br>
&gt; rolls this function for itself but would prefer to have it in the<br>
&gt; image.<br>
&gt;<br>
&gt; It should be on Symbol, not String, because we&#39;re talking about method<br>
&gt; selectors, which are always Symbols.<br>
<br>
I had debated putting the methods on Symbol, but I had (and still<br>
have) no idea whether or not they would always be Symbols, and not<br>
user input.<br>
<br>
I would not oppose moving them to Symbol, and adjusting the tests.<br>
<br>
&gt; The proposal to put it in a &quot;utility&quot; class reminds me of an old Java<br>
&gt; gig, where we couldn&#39;t extend classes with additional methods.  Proper<br>
&gt; delegation of a needed behavior is not &quot;monkey patching&quot;, which<br>
&gt; carries a derogatory connotation.<br>
<br>
Yes, which is half of why I use the term :)<br>
<br>
More seriously, in Ruby it&#39;s considered a bad smell, but in Ruby you<br>
don&#39;t interact with a running system. So in Ruby, it&#39;s really hard to<br>
find out which packages overwrote each other&#39;s patches, whereas the<br>
problem is much easier to debug and to fix in Smalltalk.<br>
<br>
It is still a problem in Smalltalk, which is why we have such an<br>
aversion to Monticello overrides. Environments could offer the chance<br>
to _with an Environment_ add methods to classes. But to do that<br>
properly you&#39;d need to change method lookup. I _think_ that means you<br>
end up with Newspeak&#39;s &quot;comb&quot; method lookup? Eliot could say for sure.<br></blockquote><div><br></div><div>I&#39;m not sure one needs to change the VM at all.  First, I think one can get a long way with an environment pragma:</div>
<div><br></div><div>    myExtension</div><div>        &lt;environment: MyEnvironment&gt;</div><div>        ^AGlobalInMyEnvironment</div><div><br></div><div>Second, adding symbols that are private to an environment is IMO a much easier way to go than Newspeak&#39;s sends.  That&#39;s an experiment that would be fun.  The VM makes no assumptions about message selectors; they can be immediates if desired.  So having a structured object that looks like</div>
<div>    ArrayedCollection subclass: #PrivateSelector</div><div>                              instanceVariableNames: &#39;symbol environment&#39;</div><div>should be possible.  But this could well be a bigger change than environments itself.  I think it solves a lot of problems, but it&#39;s work.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
frank<br>
<br>
&gt; On Mon, Dec 2, 2013 at 4:22 AM, Frank Shearar &lt;<a href="mailto:frank.shearar@gmail.com">frank.shearar@gmail.com</a>&gt; wrote:<br>
&gt;&gt; On 2 December 2013 10:16, Bert Freudenberg &lt;<a href="mailto:bert@freudenbergs.de">bert@freudenbergs.de</a>&gt; wrote:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; On 2013-11-30, at 01:00, Frank Shearar &lt;<a href="mailto:frank.shearar@gmail.com">frank.shearar@gmail.com</a>&gt; wrote:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; On 29 November 2013 23:50, tim Rowledge &lt;<a href="mailto:tim@rowledge.org">tim@rowledge.org</a>&gt; wrote:<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; On 29-11-2013, at 3:38 PM, Frank Shearar &lt;<a href="mailto:frank.shearar@gmail.com">frank.shearar@gmail.com</a>&gt; wrote:<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; On 29 November 2013 21:51, tim Rowledge &lt;<a href="mailto:tim@rowledge.org">tim@rowledge.org</a>&gt; wrote:<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt; On 29-11-2013, at 12:43 PM, Frank Shearar &lt;<a href="mailto:frank.shearar@gmail.com">frank.shearar@gmail.com</a>&gt; wrote:<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; inherentSelectorForGetter<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt; That’s absolutely a Symbol method and really ought always have been there.<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; It wasn&#39;t clear to me either from the senders-of or the implementation<br>
&gt;&gt;&gt;&gt;&gt;&gt; whether it should go on Symbol or String, so I went with the<br>
&gt;&gt;&gt;&gt;&gt;&gt; broader/safer option, and put it on String.<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; But I take it you&#39;re voting for &quot;put it on the dang object&quot; option<br>
&gt;&gt;&gt;&gt;&gt;&gt; rather than &quot;monkey patching is evil”?<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; Guess so; methods ought to go in The Right Place. Now *defining* that place… that’s where the art is.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; And so a method that takes a string/symbol and turns it into some<br>
&gt;&gt;&gt;&gt; slightly different symbol pretty much ought to go on String/Symbol.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; I&#39;m leaning heavily towards the monkey patch option, and not just<br>
&gt;&gt;&gt;&gt; because I have the work done waiting for committing. I&#39;ll hold off on<br>
&gt;&gt;&gt;&gt; anything for the moment though, both because it has a rather large<br>
&gt;&gt;&gt;&gt; number of changes to Etoys and to give others a chance to chime in.<br>
&gt;&gt;&gt;&gt; That it&#39;s midnight here, and I&#39;m tired and hence not in the best shape<br>
&gt;&gt;&gt;&gt; to do dangerous things like commit changes has nothing at all to do<br>
&gt;&gt;&gt;&gt; with the waiting. Promise.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; frank<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Converting between setters and getters seems generally useful to me, so even if at the moment it may be only used in Etoys, I&#39;d not make it an Etoys-specific extension.<br>
&gt;&gt;<br>
&gt;&gt; Since we ship Etoys in a standard Squeak image, how about we keep<br>
&gt;&gt; these methods in Etoys until we do start mangling selectors elsewhere?<br>
&gt;&gt; In other words, pull the methods out on demand? (I have no objections<br>
&gt;&gt; to them moving out of Etoys if they do prove to be generally useful.)<br>
&gt;&gt;<br>
&gt;&gt; frank<br>
&gt;&gt;<br>
&gt;&gt;&gt; - Bert -<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;<br>
&gt;<br>
<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>best,<div>Eliot</div>
</div></div>