Path: utzoo!utgpu!watserv1!watmath!att!rutgers!usc!zaphod.mps.ohio-state.edu!wuarchive!uunet!willett!ForthNet From: ForthNet@willett.UUCP (ForthNet articles from GEnie) Newsgroups: comp.lang.forth Subject: ANS TC Magnet for LOOPS, EXIT, Term. Message-ID: <1341.UUL1.3#5129@willett.UUCP> Date: 15 Jul 90 22:58:00 GMT Organization: String, Scotch tape, and Paperclips. (in Pgh, PA) Lines: 85 Category 10, Topic 16 Message 92 Sun Jul 15, 1990 R.BERKEY [Robert] at 04:37 PDT From BAR0712.90: [This was "formatted" to a degree unreadable. I unformatted it. -dwp] <[Robert] R.BERKEY> I just noticed that FOR NEXT has "sys" on the stack. <[Hail, Denver] JAX> "buf of courz, m'sieu" <[Robert] R.BERKEY> That allows implementations some more options there, while <[Robert] R.BERKEY> disallowing branches out of FOR NEXT loops. <[Robert] R.BERKEY> DO LOOP is "dest" so that means that there is only one item <[Hail, Denver] JAX> Well, that's a poor description of DO ... LOOP then. <[Robert] R.BERKEY> on the stack. <[Hail, Denver] JAX> There oughta be SYS there. <[Robert] R.BERKEY> Which means that DO LOOP security must go elsewhere. <[Hail, Denver] JAX> I'll try to remember to mention that at Vancouver. <[Robert] R.BERKEY> But if you make DO "sys" then you can't program <[Robert] R.BERKEY> DO WHILE LOOP ELSE THEN ( add an UNLOOP somewhere ) <[Hail, Denver] JAX> the 11th commandment: ( after "thou shalt not pick ...) : <[Hail, Denver] JAX> THOU SHALT NOT UNLOOP! <[Hail, Denver] JAX> :-) <[Robert] R.BERKEY> Huh? What wrong with UNLOOP ? Jan Stout writes, 900321: > 5. ?DO ... (Why not let the orig dest duo be sys anyway?) About having "sys" in the definition, I tried to write up a proposal involving such. Here's the problem. A point of ( -- orig dest ) is that it allows a control structure to handle special processing in the case of zero iterations of the loop. ?DO ( orig0 dest0 ) ... LOOP ( orig0 ) ... \ normal loop termination ELSE ( orig1 ) ... \ zero iterations THEN But another point of the spec is that it allows a control structure to access special processing in the case of early loop termination. And both simultaneously are of interest: ?DO ( orig0 dest0 ) ... WHILE ( orig0 orig1 dest0 ) ... LOOP ( orig0 orig1 ) ... \ normal loop termination ELSE ( orig0 orig2 ) ... UNLOOP \ early loop termination THEN ( orig0 ) ... ELSE ( orig3 ) ... \ zero iterations termination THEN Since the "sys" is for resolution by the loop, the logical order for ?DO is: ( orig0 sys0 dest0 ) This couples sys0 and dest0. But since WHILE swaps the top of the control flow stack, ( orig0 sys0 orig1 dest0 ), there's then no way for LOOP to find the "sys". Thereby, any extra values left by ?DO must be paralleled by any "dest" word, such as BEGIN , so that WHILE will know how to do the swap. It may not be ideal, but the compiling part of ?DO can have it's own stack, or use the return stack, or all of the other control structures can be modified such that dest and orig always use the same number of stack elements. Now, as to why BASIS gives FOR NEXT "sys" rather than control-flow stack indications, I don't know. ----- This message came from GEnie via willett through a semi-automated process. Report problems to: uunet!willett!dwp or willett!dwp@hobbes.cert.sei.cmu.edu