<div dir="ltr">+1 nice!<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le mar. 23 juin 2020 à 20:23, Eliot Miranda <<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</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 dir="ltr"><div dir="ltr">Hi All,<div><br></div><div>    I juts had occasion to use generators in anger for the first time.  I was trying to fnd out why a clone of a prse tree was reporting that it was not the same tree.  Generators made enumerating all nodes in each tree together trivial:</div><div><br></div><div><div>| them |</div><div>them := Generator on: [:g| newTree nodesDo: [:n| g yield: n]].</div><div>parseTree nodesDo:</div><div><span style="white-space:pre-wrap">  </span>[:n| | twin |</div><div><span style="white-space:pre-wrap">    </span>twin := them next.</div><div><span style="white-space:pre-wrap">       </span>(n isSameAs: twin) ifFalse:</div><div><span style="white-space:pre-wrap">              </span>[self halt]]</div><div><br></div><div>My message though comes from noticing that generators yield their values via next, so why not use nextPut: instead of yield: ?</div><div><br></div><div>e.g. I think this is better:</div><div><br></div><div><div>| them |</div><div>them := Generator on: [:g| newTree nodesDo: [:n| g nextPut: n]].</div><div>parseTree nodesDo:</div><div><span style="white-space:pre-wrap">        </span>[:n| | twin |</div><div><span style="white-space:pre-wrap">    </span>twin := them next.</div><div><span style="white-space:pre-wrap">       </span>(n isSameAs: twin) ifFalse:</div><div><span style="white-space:pre-wrap">              </span>[self halt]]</div></div><div><br></div><div dir="ltr"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div></div></div></div></div>
<br>
</blockquote></div>