<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 class="gmail-Apple-tab-span" style="white-space:pre">  </span>[:n| | twin |</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">  </span>twin := them next.</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">     </span>(n isSameAs: twin) ifFalse:</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">            </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 class="gmail-Apple-tab-span" style="white-space:pre">      </span>[:n| | twin |</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">  </span>twin := them next.</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">     </span>(n isSameAs: twin) ifFalse:</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">            </span>[self halt]]</div></div><div><br></div><div dir="ltr" class="gmail_signature"><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>