<div dir="ltr">To be absolutely thorough, also consider how the new: message is associated to basicNew:  or super new: and initialize: for variable subclasses - or eventually just initialize: for those quaking like a variable subclass...<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le jeu. 5 sept. 2019 à 00:27, Thiede, Christoph <<a href="mailto:Christoph.Thiede@student.hpi.uni-potsdam.de">Christoph.Thiede@student.hpi.uni-potsdam.de</a>> a écrit :<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>


<div dir="ltr">
<div id="gmail-m_-1368024574941672016x_divtagdefaultwrapper" dir="ltr" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif">
<p>Okay, thank you for the really comprehensive clarification :)</p>
<p><br>
</p>
<p>I was already aware of the "basic" meaning of #basicNew, but I also met a pattern that told me to only use super to call the same-named base method. It feels like breaking with the law of encapsulation when you can always refer to the base version of a method
 that has been explicitly changed in the current class.</p>
<p><br>
</p>
<p>But I guess in this case, it is more important to deal with possible logic that could be introduced in (Proto)Object>>#initialize.</p>
<p><br>
</p>
<p>Christoph</p>
<div id="gmail-m_-1368024574941672016x_Signature">
<div name="x_divtagdefaultwrapper">
<div><font size="2" color="#808080"></font></div>
</div>
</div>
</div>
<hr style="display:inline-block;width:98%">
<div id="gmail-m_-1368024574941672016x_divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>Von:</b> Squeak-dev <<a href="mailto:squeak-dev-bounces@lists.squeakfoundation.org" target="_blank">squeak-dev-bounces@lists.squeakfoundation.org</a>> im Auftrag von tim Rowledge <<a href="mailto:tim@rowledge.org" target="_blank">tim@rowledge.org</a>><br>
<b>Gesendet:</b> Mittwoch, 4. September 2019 23:43:22<br>
<b>An:</b> The general-purpose Squeak developers list<br>
<b>Betreff:</b> Re: [squeak-dev] The Trunk: Collections-mt.851.mcz</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt">
<div class="gmail-m_-1368024574941672016PlainText">Well, to try to explain this mostly to Christoph, #basicNew should do only the primitive creation of the chunk of object memory, hence the 'basic' (and that does include some hacks for certain classes likeBoxedFloat etc).
<br>
#new and other initial creation methods can do further things, like setting initial values of some instance variables, registering external resources, etc.<br>
<br>
So they do not in general work equivalently, deliberately. At the most basic level, #new sends #basicNew to create the memory and then #initialize to do the ... initialisation. If that initialize does stuff your specific needs would prefer to avoid, use #basicNew
 and your own initialisation sequence.<br>
<br>
As an example, consider WriteStream>on:from:to: which uses `self basicNew`. It could use #new without any difference in effect because there is no implementation of #initialize for WriteStreams until you get to the null version in ProtoObject.
<br>
<br>
In contrast, imagine a class where the normal use needs a load of instance variable to be set up just so, but you have a need for a quite different setup and it would waste a lot of cycles to do the typical init and then overwrite almost all of it. That might
 justify a separate creation method that uses #basicNew and a specialised init method.
<br>
<br>
There's also the question of self vs super in your original question. Remember, super is for case where you need to skip up the class tree starting in the superclass of *the class in which the method you are running* lives. This is *not* always the super class
 of the object executing the method. Lots of people get this wrong. <br>
<br>
There are good explanations of the real effects of this crucial point in the Blue Book etc and you really need an example class tree with at least 4 level and it's too long to type here. Suffice to say that the practical difference between `self basicNew` and
 `super new` can be significant.<br>
<br>
> On 2019-09-04, at 2:07 PM, Nicolas Cellier <<a href="mailto:nicolas.cellier.aka.nice@gmail.com" target="_blank">nicolas.cellier.aka.nice@gmail.com</a>> wrote:<br>
> <br>
> Hmm, I just starred at method 'source with it' in a SpurVMMaker image and got<br>
> - 252 hits for 'self basicNew';<br>
> - 109 hits for 'super new'.<br>
> <br>
> So it might depend on context... This would deserve more statistics (age of method, initials, whether new is raising an Error or not, whether instance side initialize does nothing or the wrong thing, etc...)<br>
> <br>
> Le mer. 4 sept. 2019 à 22:38, tim Rowledge <<a href="mailto:tim@rowledge.org" target="_blank">tim@rowledge.org</a>> a écrit :<br>
> <br>
> <br>
> > On 2019-09-04, at 12:58 PM, Thiede, Christoph <<a href="mailto:Christoph.Thiede@student.hpi.uni-potsdam.de" target="_blank">Christoph.Thiede@student.hpi.uni-potsdam.de</a>> wrote:<br>
> > <br>
> > Thank you :)<br>
> > <br>
> > A very minor question: Would you favor [self basicNew] over [super new]? It will work completely equivalently, but what is the better style?<br>
> <br>
> ^super new<br>
> <br>
> `self basicNew` will not always work equivalently. And I can almost guarantee it will always do the wrong thing just when you feel sure it is doing the right thing. And you will suffer Debugging Hell.<br>
> <br>
> <br>
> tim<br>
> --<br>
> tim Rowledge; <a href="mailto:tim@rowledge.org" target="_blank">tim@rowledge.org</a>; <a href="http://www.rowledge.org/tim" target="_blank">http://www.rowledge.org/tim</a><br>
> Why use one word when two polysyllabic agglomerates will do?<br>
> <br>
> <br>
> <br>
> <br>
> <br>
> <br>
<br>
<br>
tim<br>
--<br>
tim Rowledge; <a href="mailto:tim@rowledge.org" target="_blank">tim@rowledge.org</a>; <a href="http://www.rowledge.org/tim" target="_blank">http://www.rowledge.org/tim</a><br>
Computing Dictionary: LOOP: (go to LOOP)<br>
<br>
<br>
<br>
</div>
</span></font>
</div>

<br>
</blockquote></div>