<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p>Hi Nicolas,</p>
<p><br>
</p>
<p>I don't see your point of #doWhileTrue: being not idiomatic. What exactly do you mean by that except for "unfamiliar"?</p>
<p><br>
</p>
<p>However, I agree that the names are confusing, compared to #whileTrue: etc.</p>
<p>+1 for naming them #repeatWhile: and #repeatUntil: instead!</p>
<p><br>
</p>
<p>> <span style="font-size: 12pt;">But that still means that we have two ways to express exactly the same thing, which by first principle should not be</span></p>
<div>> (economy of implementation, of tests, of documentation, etc... small is beautiful !).</div>
<div><br>
</div>
<div>Well, that's another a question of semantics, again. :) Remember my examples about #ifNotNil:/#==> etc.? Convenience methods support ease of writing and reading.</div>
<div><br>
</div>
<div>> <span style="font-size: 12pt;">Really, not kidding?</span>
<div><br>
</div>
<div>The example is taken from BookMorph >> #saveOnUrlPage:. I did not read it in context, too ^^</div>
<div><br>
</div>
<div>> <span style="font-size: 12pt;">Is the following better?</span>
<div>> </div>
<div>> [newPlace := self getNewPlace.</div>
<div>> file:= ServerFile new fullPath: newPlace.</div>
<div>> file exists] whileTrue</div>
<div><br>
</div>
<div>In my opinion, #repeatUntil: would still be better :)</div>
<div><br>
</div>
<div>> <span style="font-size: 12pt;">Note that I did not add non local block return in the middle of the block...</span>
<div>> It was in the original method, doWhileTrue did not solve it.</div>
<div><br>
</div>
<div>I was referring to blockReturn in the bytecode sense. Here is another example of confusing blockReturns:</div>
<div><br>
</div>
<div>(foo satisfiesSomeCondition or: [|baz|</div>
<div>    baz := bar asBaz.</div>
<div>    foo cacheDuring: [</div>
<div>        baz satisfiesSomeOtherCondition]])</div>
<div>            ifTrue: [...]</div>
<div><br>
</div>
<div>Hard to follow the control flow, isn't it? If I have the choice, I avoid these statements and use blocks,</div>
<div>either) to pass a piece of code to another object and compose control flows,</div>
<div>or) to explicitly pass a value to be evaluated lazily.</div>
<div>Both at once can be confusing. I think there is a good reason why there is no syntax for blockReturn like we have one for methodReturn (^).</div>
<div><br>
</div>
<div>Best,</div>
<div>Christoph</div>
</div>
</div>
</div>
<p></p>
<div id="Signature">
<div id="divtagdefaultwrapper" 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" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:; margin:0">
<div><font size="2" color="#808080"></font></div>
</div>
</div>
</div>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>Von:</b> Squeak-dev <squeak-dev-bounces@lists.squeakfoundation.org> im Auftrag von Nicolas Cellier <nicolas.cellier.aka.nice@gmail.com><br>
<b>Gesendet:</b> Montag, 30. März 2020 20:56:43<br>
<b>An:</b> The general-purpose Squeak developers list<br>
<b>Betreff:</b> Re: [squeak-dev] #doWhileTrue: (was: The Trunk: System-nice.1149.mcz)</font>
<div> </div>
</div>
<div>
<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>
</div>
</body>
</html>