<div dir="ltr"><div>Tim,<br></div><div>You can discourage non private use if you write them like this:</div><div>foo</div><div> foo ifNil:[foo := OrderedCollection new].</div><div> ^nil</div><div><br></div><div>/s</div><div><br></div><div>Best,</div><div>Karl<br></div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jul 21, 2020 at 7:08 PM tim Rowledge <<a href="mailto:tim@rowledge.org">tim@rowledge.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
<br>
> On 2020-07-21, at 1:36 AM, Marcel Taeumel <<a href="mailto:marcel.taeumel@hpi.de" target="_blank">marcel.taeumel@hpi.de</a>> wrote:<br>
> <br>
> I can choose to initialize an instVar eagerly in #initialize or lazily in its accessor via #ifNil:. Yet, the latter requires me to change that accessor to something not being a quick return.<br>
<br>
I've always been a bit ambivalent about the lazy initialisation stuff; not that it doesn't have uses. The problematic bit in my experience is tied to the lack of properly private messages and the disappointing propensity of people to treat Smalltalk as C code.<br>
<br>
To explain: one decides to have lazy init for an instvar and so creates a methods named as the instvar that does the nil check and init dance. Great - now you can write<br>
`self foobleDong`<br>
and guarantee to get a useful answer. The problem now is that you have made your class into little more than a C struct. Any old Thomas, Richard or Harold can send #foobleDong and get at the internal state of your object. I don't like that.<br>
*If* we had private methods one could mark foobleDong as private and thereby safely use it internally. <br>
<br>
I see far too much 'Cmalltalk' where messages are being sent as if they were C struct accessor operators. I really hate seeing<br>
`myThing foo fum bar baz bing: myThing foo fum bar baz bing + 1`<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" rel="noreferrer" target="_blank">http://www.rowledge.org/tim</a><br>
"Bother!" said Pooh, as he stood up to his waist in a cow pat.<br>
<br>
<br>
<br>
</blockquote></div>