<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le lun. 30 mars 2020 à 19:58, Thiede, Christoph <<a href="mailto:Christoph.Thiede@student.hpi.uni-potsdam.de" target="_blank">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 dir="ltr">
<div id="m_7379146918319137251gmail-m_-8548527886577089854divtagdefaultwrapper" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif" dir="ltr">
<div id="m_7379146918319137251gmail-m_-8548527886577089854divtagdefaultwrapper" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols" dir="ltr">
<p>Hi Nicolas,</p>
<p><br>
</p>
<p>> <span style="font-size:12pt">There is no other sender of doWhileFalse: doWhileTrue: and my advice would be to deprecate them. YAGNI.</span></p>
<div><br>
</div>
<div>So my image actually contains around two dozen senders of #doWhileTrue: and #doWhileFalse: (Squot, Pheno and some of my own code). As mentioned somewhere else in the past, I actually like them and find them very useful.</div>
<div><br>
</div>
<div>In my opinion, many senders of #whileTrue and #whileFalse should be refactored to use #doWhileTrue:/#doWhileFalse:. Here is a random example:</div>
<div><br>
</div>
<div>[newPlace := self getNewPlace.</div>
<div>
<div>dir := ServerFile new fullPath: newPlace.</div>
<div>(dir includesKey: dir fileName)] whileTrue.</div>
<div><br>
</div>
<div>I find that's ugly and counter-intuitive! I would rewrite this in the following way:</div>
<br>
</div>
<div>
<div style="font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols;font-size:16px">
[newPlace := self getNewPlace.</div>
<div style="font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols;font-size:16px">
<div>dir := ServerFile new fullPath: newPlace]</div>
<div>    doWhileTrue: [dir includesKey: dir fileName].</div>
</div>
<br></div></div></div></div></blockquote><div><br></div>The first thing that upsets me is that they are not idiomatic. #whileTrue: and in a lesser way #whileTrue are.<br>The second thing that upsets me is that the names are REALLY too close to #whileTrue:</div><div class="gmail_quote">So at first, I was confused by the fact that they looked like synonyms.<br>Then I wondered exactly the same, what the hell has to be true?<br>Especially when the sole sender in trunk is [] doWhileTrue: true ;)<br><br>IMO, they might be better spelled #repeatWhile: and #repeatUntil:</div><div class="gmail_quote">But that still means that we have two ways to express exactly the same thing, which by first principle should not be</div><div class="gmail_quote">(economy of implementation, of tests, of documentation, etc... small is beautiful !).<br><br>We might discuss which is more readable, maybe<br><br>[newPlace := self getNewPlace.<br>dir := ServerFile new fullPath: newPlace]<br>    repeatWhile: [dir includesKey: dir fileName].<br><br>is more revealing than:<br><br>[newPlace := self getNewPlace.<br>dir := ServerFile new fullPath: newPlace.<br>(dir includesKey: dir fileName)] whileTrue.<br></div><div class="gmail_quote">
<div class="gmail_quote"><br></div><div class="gmail_quote">IMO, it's a biased example, because the whole snippet is un-comprehensible.</div><div class="gmail_quote">So a ServerFile behaves like a ServerDirectory (from which it inherits...), oh nice (???).<br></div><div class="gmail_quote">And a ServerFile which would includes some item with same name as itself would mean that the file already exists... </div>

</div><div class="gmail_quote">Really, not kidding?
<br></div><div class="gmail_quote"><br></div><div class="gmail_quote">So IMO that's what makes the snippet illegible, not whileTrue.</div><div class="gmail_quote">Is the following better?</div><div class="gmail_quote"><br></div><div class="gmail_quote">[newPlace := self getNewPlace.<br></div><div class="gmail_quote">file:= ServerFile new fullPath: newPlace.<br></div><div class="gmail_quote">file exists] whileTrue</div><div class="gmail_quote"><br>

</div><div class="gmail_quote">Anyway, the second one is there for such a long time that you can't expunge it that easily. It's idiomatic...<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"><div id="m_7379146918319137251gmail-m_-8548527886577089854divtagdefaultwrapper" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif" dir="ltr"><div id="m_7379146918319137251gmail-m_-8548527886577089854divtagdefaultwrapper" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols" dir="ltr"><div>
</div>
<p></p>
<div id="m_7379146918319137251gmail-m_-8548527886577089854Signature">
<div id="m_7379146918319137251gmail-m_-8548527886577089854divtagdefaultwrapper" dir="ltr" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols">
<div name="divtagdefaultwrapper">
<div><font size="2" color="#808080"></font></div>
</div>
</div>
</div>
The latter just reads easier. blockReturns in multi-statement blocks are not really intuitive.</div></div></div></blockquote><div><br></div><div>Note that I did not add non local block return in the middle of the block...</div><div>It was in the original method, doWhileTrue did not solve it.</div><div><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 id="m_7379146918319137251gmail-m_-8548527886577089854divtagdefaultwrapper" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif" dir="ltr">
<div id="m_7379146918319137251gmail-m_-8548527886577089854divtagdefaultwrapper" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols" dir="ltr">
In the first version, when scanning the method quickly, I read "okay, something with places and directories is done, while true ...," I wonder "what has to be true?" and have to look back to the end of the block and find the beginning of the last statement.</div>
<div id="m_7379146918319137251gmail-m_-8548527886577089854divtagdefaultwrapper" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols" dir="ltr">
But in the second version, I read "okay, something with places and directories is done, while that directory matches this specific condition." This version directly draws my attention to the important condition.</div>
<div id="m_7379146918319137251gmail-m_-8548527886577089854divtagdefaultwrapper" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols" dir="ltr">
<br>
</div>
<div id="m_7379146918319137251gmail-m_-8548527886577089854divtagdefaultwrapper" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols" dir="ltr">
Happy to hear your counterarguments :-)</div>
<div id="m_7379146918319137251gmail-m_-8548527886577089854divtagdefaultwrapper" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols" dir="ltr">
<br>
</div>
<div id="m_7379146918319137251gmail-m_-8548527886577089854divtagdefaultwrapper" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols" dir="ltr">
Best,</div>
<div id="m_7379146918319137251gmail-m_-8548527886577089854divtagdefaultwrapper" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols" dir="ltr">
Christoph<br>
<br>
<div style="color:rgb(0,0,0)">
<div>
<hr style="display:inline-block;width:98%">
<div id="m_7379146918319137251gmail-m_-8548527886577089854x_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 <a href="mailto:commits@source.squeak.org" target="_blank">commits@source.squeak.org</a> <<a href="mailto:commits@source.squeak.org" target="_blank">commits@source.squeak.org</a>><br>
<b>Gesendet:</b> Montag, 30. März 2020 12:51 Uhr<br>
<b>An:</b> <a href="mailto:squeak-dev@lists.squeakfoundation.org" target="_blank">squeak-dev@lists.squeakfoundation.org</a>; <a href="mailto:packages@lists.squeakfoundation.org" target="_blank">packages@lists.squeakfoundation.org</a><br>
<b>Betreff:</b> [squeak-dev] The Trunk: System-nice.1149.mcz</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt">
<div>Nicolas Cellier uploaded a new version of System to project The Trunk:<br>
<a href="http://source.squeak.org/trunk/System-nice.1149.mcz" id="m_7379146918319137251gmail-m_-8548527886577089854LPlnk967140" target="_blank">http://source.squeak.org/trunk/System-nice.1149.mcz</a><br>
<br>
==================== Summary ====================<br>
<br>
Name: System-nice.1149<br>
Author: nice<br>
Time: 30 March 2020, 12:50:26.196366 pm<br>
UUID: ece53b0b-24d2-4d4b-bc91-6794a661f886<br>
Ancestors: System-ul.1148<br>
<br>
avoid neuron storming [...] doWhileTrue: true, it just means [...] repeat<br>
<br>
There is no other sender of doWhileFalse: doWhileTrue: and my advice would be to deprecate them. YAGNI.<br>
<br>
=============== Diff against System-ul.1148 ===============<br>
<br>
Item was changed:<br>
  ----- Method: MOFile>>searchByHash: (in category 'experimental') -----<br>
  searchByHash: aString<br>
         | hashValue nstr index incr key |<br>
         hashValue :=  self hashPjw: aString.<br>
         incr := 1 + (hashValue \\ (hashTableSize -2)).<br>
         index := (hashValue \\ hashTableSize) .<br>
         [        nstr := (hashTable at: index +1 ).<br>
                 nstr = 0 ifTrue: [^nil].<br>
                 key := self originalString: nstr.<br>
                 key = aString ifTrue: [^self translatedString: nstr].<br>
                 index >= (hashTableSize - incr) <br>
                                 ifTrue: [index := index - (hashTableSize - incr)  ]<br>
                                 ifFalse:[index := index + incr].        <br>
+        ] repeat!<br>
-        ] doWhileTrue: true.!<br>
<br>
<br>
</div>
</span></font></div>
</div>
</div>
</div>

<br>
</blockquote></div></div>