Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #10413
| From | Arnold Doray <invalid@invalid.com> |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: DO... LOOP question |
| Date | 2012-03-24 17:29 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <jkl0a4$983$1@dont-email.me> (permalink) |
| References | <jk50b8$i6f$1@dont-email.me> <e080c1d3-3998-4f79-9c75-101ff8ac61f3@p6g2000yqi.googlegroups.com> <jkacp1$muf$1@dont-email.me> <88b3c078-4eae-4af0-af5e-6ce46b37db96@9g2000pbn.googlegroups.com> |
On Tue, 20 Mar 2012 11:41:43 -0700, BruceMcF wrote: > On Mar 20, 12:54 pm, Arnold Doray <inva...@invalid.com> wrote: >> On Sun, 18 Mar 2012 09:41:53 -0700, BruceMcF wrote: >> >> < good stuff snipped > >> >> Thank you for the detailed solutions! >> >> You could take your idea one step further, incorporating the number of >> leaves as a separate variable that has to be saved/restored like the >> limit and biased count. This simplifies the "rake leaves" and makes the >> solution completely portable (I think), without the need for a >> compatability harness. > > I'm not sure that it does: > > ... DO ... finished? IF UNLOOP LEAVE THEN ... LOOP > > then the THEN resolves the jump from the LEAVE and the LOOP resolves he > jump from the LEAVE. > > If you know that the ORIG is on the stack and know the *size* of an > ORIG, you could stash the leave ORIG under the J info on the return > stack, which is by specification unavailable until after the DO-LOOP has > been completed, and count ORIG's in a side variable. > > The portability harness and implementation of that "left to the reader". Thanks again Bruce. Some wishful thinking -- perhaps what's needed are 2 additional words to move items between the compilation stack and the return stack. Call them CS>R and R>CS . In Forths that use the data stack as the compilation stack, this would probably be easy to do. Given CS>R and R>CS this might work: : LEAVE ` AHEAD ` CS>R ; IMMEDIATE : (LEAVE-RESOLVE) loop-leaves @ BEGIN dup 0 > WHILE ` R>CS ` THEN 1- REPEAT ; Besides its relative simplicity, the advantage of this solution is that it would probably also work for LEAVE'ing other looping constructs, if they were retrofitted to save the leave count on entering the loop and to use (LEAVE-RESOLVE) at the loop exit. For example: : (SAVE-LEAVE-COUNT) loop-leaves @ ; : WHILE ` (SAVE-LEAVE-COUNT) ` >R ` WHILE ; IMMEDIATE : (RESTORE-LEAVE-COUNT) loop-leaves ! ; : REPEAT ` (LEAVE-RESOLVE) ` REPEAT ` R> ` (RESTORE-LEAVE-COUNT) ; IMMEDIATE Cheers, Arnold
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar
DO... LOOP question Arnold Doray <invalid@invalid.com> - 2012-03-18 15:52 +0000
Re: DO... LOOP question Coos Haak <chforth@hccnet.nl> - 2012-03-18 17:08 +0100
Re: DO... LOOP question BruceMcF <agila61@netscape.net> - 2012-03-18 09:41 -0700
Re: DO... LOOP question Coos Haak <chforth@hccnet.nl> - 2012-03-18 20:51 +0100
Re: DO... LOOP question BruceMcF <agila61@netscape.net> - 2012-03-18 14:37 -0700
Re: DO... LOOP question BruceMcF <agila61@netscape.net> - 2012-03-18 15:56 -0700
Re: DO... LOOP question Coos Haak <chforth@hccnet.nl> - 2012-03-19 01:04 +0100
Re: DO... LOOP question BruceMcF <agila61@netscape.net> - 2012-03-18 17:25 -0700
Re: DO... LOOP question BruceMcF <agila61@netscape.net> - 2012-03-18 17:43 -0700
Re: DO... LOOP question BruceMcF <agila61@netscape.net> - 2012-03-18 18:48 -0700
Re: DO... LOOP question BruceMcF <agila61@netscape.net> - 2012-03-18 21:49 -0700
Re: DO... LOOP question BruceMcF <agila61@netscape.net> - 2012-03-19 11:39 -0700
Re: DO... LOOP question BruceMcF <agila61@netscape.net> - 2012-03-20 12:16 -0700
Re: DO... LOOP question Arnold Doray <invalid@invalid.com> - 2012-03-20 16:54 +0000
Re: DO... LOOP question BruceMcF <agila61@netscape.net> - 2012-03-20 11:41 -0700
Re: DO... LOOP question Arnold Doray <invalid@invalid.com> - 2012-03-24 17:29 +0000
Re: DO... LOOP question Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-03-24 13:22 -0500
Re: DO... LOOP question Arnold Doray <invalid@invalid.com> - 2012-03-25 04:09 +0000
Re: DO... LOOP question Coos Haak <chforth@hccnet.nl> - 2012-03-25 13:49 +0200
Re: DO... LOOP question Arnold Doray <invalid@invalid.com> - 2012-03-27 17:47 +0000
Re: DO... LOOP question Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-03-25 19:45 +0000
Re: DO... LOOP question Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-03-26 04:26 -0500
Re: DO... LOOP question BruceMcF <agila61@netscape.net> - 2012-03-26 07:28 -0700
Re: DO... LOOP question Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-03-26 10:03 -0500
Re: DO... LOOP question Coos Haak <chforth@hccnet.nl> - 2012-03-26 18:47 +0200
Re: DO... LOOP question BruceMcF <agila61@netscape.net> - 2012-03-26 09:53 -0700
Re: DO... LOOP question Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-03-27 11:21 +0000
Re: DO... LOOP question Helmar Wodtke <helmwo@gmail.com> - 2012-03-27 04:34 -0700
Re: DO... LOOP question Coos Haak <chforth@hccnet.nl> - 2012-03-27 17:33 +0200
Re: DO... LOOP question Helmar Wodtke <helmwo@gmail.com> - 2012-03-27 09:19 -0700
Re: DO... LOOP question BruceMcF <agila61@netscape.net> - 2012-03-27 12:20 -0700
Re: DO... LOOP question "Elizabeth D. Rather" <erather@forth.com> - 2012-03-27 09:34 -1000
Re: DO... LOOP question BruceMcF <agila61@netscape.net> - 2012-03-27 13:00 -0700
Re: DO... LOOP question Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-03-26 20:16 -0700
Re: DO... LOOP question BruceMcF <agila61@netscape.net> - 2012-03-24 11:37 -0700
Re: DO... LOOP question Arnold Doray <invalid@invalid.com> - 2012-03-25 06:39 +0000
Re: DO... LOOP question BruceMcF <agila61@netscape.net> - 2012-03-25 06:19 -0700
Re: DO... LOOP question "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-03-21 05:48 -0400
Re: DO... LOOP question BruceMcF <agila61@netscape.net> - 2012-03-21 08:36 -0700
Re: DO... LOOP question BruceMcF <agila61@netscape.net> - 2012-03-21 11:24 -0700
Re: DO... LOOP question Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-03-21 03:01 -0700
Re: DO... LOOP question Arnold Doray <invalid@invalid.com> - 2012-03-24 17:44 +0000
Re: DO... LOOP question Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-03-25 11:57 +0000
Re: DO... LOOP question Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-03-26 20:14 -0700
Re: DO... LOOP question Arnold Doray <invalid@invalid.com> - 2012-03-27 16:46 +0000
csiph-web