Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!paperboy!think.com!sdd.hp.com!elroy.jpl.nasa.gov!usc!wuarchive!uunet!mcsun!hp4nl!tuegate.tue.nl!rc6.urc.tue.nl!eutws1.win.tue.nl From: wsbusup@eutws1.win.tue.nl (Jan Stout) Newsgroups: comp.lang.forth Subject: FOR -I -R> NEXT Keywords: DO ?DO I LEAVE ?LEAVE LOOP +LOOP ?FOR NEXT Message-ID: <437@rc6.urc.tue.nl> Date: 19 Feb 91 15:57:15 GMT Sender: USENET News System Organization: Eindhoven University of Technology, The Netherlands Lines: 54 MB>> I tend to agree on the readability & don't consider Mitch's 0 ?DO a real MB>> solution, letting the programmer type what he knows will be 'ignored' by MB>> the compiler.(see below) MB> MB>Why is this optimization any different from any other optimization? MB> MB>If the compiler can generate better code by recognizing a special case, MB>then why not let it do so? MB> If the FOR NEXT approach of using 1 parameter is more usefull, I'd find it strange to recognize this fact by using 0 ?DO LOOP to express that idea. MB>(There is one less-serious problem too: what is the name of the FOR .. NEXT MB>loop index?). The key issue, in my view, of the FOR NEXT approach is to keep the index nameless, and in fact allow no reference to it at all. This to prevent people to use to VERY implementation-dependant >R R@ R>. By the way I is also inappropriate (see Robert Berkeys DO LOOP implementation). In my opion ONE UPCOUNTING index is so scarcely used that using the DO LOOP's I index is often inconvenient. (Of course the same applies to the DOWNCOUNTING FOR NEXT index). To keep the indexaddressing uniform I therefore propose to use on (data:)stack indexes. The more-serious problem U didn't mention is that of the FOR NEXT 'LEAVE', for it's absense in a way caused ppl to code FOR WHILE NEXT 2R> >R DROP THEN loops thereby making explicit use FOR NEXT implementation details. LEAVE is supposed to factor out this details. BTW following your advise on introducing old names, in my system PASS is used to skip the NEXT. (I apoligize if this name or function already is in BASIS xx, but the last un-RTFed BASIS I received was #10 :) Implementation note: In my system ?FOR executes n times by branching directly to NEXT after saving the index. NEXT checks for a <>0, if it's there it tries to remove it by decrementing and finally branching to the code after ?FOR. if it's not there then 0 is, so it's time to drop the index and continue with the code following. PASS removes the <>0, inserts a 0 and branches to NEXT. (Thus leaving the index removal to NEXT exclusively) MB>Mitch Bradley, wmb@Eng.Sun.COM Jan Stout, wsbusup@eutws1.win.tue.nl PS I like the proposed OBSOLETE (EJ).