FOR -I -R> NEXT 
Author Message
 FOR -I -R> NEXT

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.

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)



PS I like the proposed OBSOLETE (EJ).



Sat, 07 Aug 1993 23:57:15 GMT  
 FOR -I -R> NEXT


Quote:
> 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.

I agree.  DO  LOOP  and FOR  NEXT are not exactly isomorphic, but they
overlap by a lot.

Quote:
> 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.


I like this idea.  It has always bugged me that DO LOOP has muddied the
stacks so as to complicate early exit and access to the data stack.  
BLEAH.  My preferred idea (hare freakin' brained) is something more like:
        Count ' Word-To-Repeat DO-TIMES

I'm still up in the air about how and even if, Word-To-Repeat, can tell
DO-TIMES to stop early.  DO-TIMES should not pollute the data nor the
return stacks (I'm a little less adament about the return stack).

Quote:
> PS I like the proposed OBSOLETE (EJ).

Me too.

-Doug
---



Mon, 09 Aug 1993 09:20:05 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. bug in PositionableStream>>next:

2. HELP>>>>>>>Fortran-Pascal Linking

3. >>>>>>>FROM SMTK TO C++

4. LOGO-L> Re: Next Generation in 3D

5. Scheme->C for NeXT

6. Scheme->C for NeXT?

7. determining the next model number >= any arbitrary number

8. ><><><><>Heeeeeeeeeeeeeeelp on INT 14!><><><><><>

9. Next vs. Access.fliename.Next()

10. NeXT/NeXT STEP Oberon?

11. Array#next - Enumerable#next ?

12. call-next-next-method

 

 
Powered by phpBB® Forum Software