Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #48526
| From | "HAA" <someone@microsoft.com> |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: Implementation of LEAVE? |
| Date | 2016-06-26 15:31 +1000 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <nknp7r$12ei$1@gioia.aioe.org> (permalink) |
| References | <cf94fe95-4400-43db-8981-0c24d63e0749@googlegroups.com> |
alexinbeijing@gmail.com wrote: > Dear comp.lang.forth, > > Greetings! I'm hoping one of you Forth wizards can enlighten me on the most practical > way to implement (ANS Forth) LEAVE. (I'm implementing Forth as a way of learning about > it.) > > IF..ELSE..THEN, BEGIN..AGAIN, BEGIN..WHILE..REPEAT, etc. all use the data stack to > store unresolved jump origins and destinations. But because LEAVE follows a different > nesting discipline from all of these other control flow structures, it can't use the > data stack to store its jump origin, or things get messed up when (for example) you put > a LEAVE inside an IF..THEN block. > > I have read that some Forths use the retstack for storing LEAVE jump origins, then > resolve all of them when the corresponding LOOP or +LOOP is reached. This seems to make > sense. > > But then I have also read things like this: > > (http://www.figuk.plus.com/build/heart.htm) > The behaviour of ?DO and LEAVE has led to some strange > implementations. For example, F83 DO pushes the exit > address of the loop on the return stack so that it can > be picked up and used by LEAVE, and it does so whether > that particular loop has a LEAVE or not. This version > is more rational. LEAVE compiles its own exit address > and doesn't mess with the return stack. It doesn't need to be complicated. This one is for ITC/DTC. Compiler security checking not shown. 0 value leav : DO postpone (do) leav >mark dup to leav postpone begin ; immediate : ?DO postpone (?do) leav >mark dup to leav postpone begin ; immediate : LEAVE postpone (leave) leav , ; immediate : LOOP postpone (loop) <resolve postpone then to leav ; immediate : +LOOP postpone (+loop) <resolve postpone then to leav ; immediate
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Implementation of LEAVE? alexinbeijing@gmail.com - 2016-06-23 02:01 -0700
Re: Implementation of LEAVE? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-06-23 05:45 -0500
Re: Implementation of LEAVE? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-06-23 11:53 +0000
Re: Implementation of LEAVE? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-06-23 12:06 -0500
Re: Implementation of LEAVE? Paul Rubin <no.email@nospam.invalid> - 2016-06-23 12:19 -0700
Re: Implementation of LEAVE? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-06-24 03:05 -0500
Re: Implementation of LEAVE? JennyB <jennybrien@googlemail.com> - 2016-06-24 02:14 -0700
Re: Implementation of LEAVE? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-06-25 04:19 -0500
Re: Implementation of LEAVE? JennyB <jennybrien@googlemail.com> - 2016-06-25 03:38 -0700
Re: Implementation of LEAVE? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-06-25 11:00 -0500
Re: Implementation of LEAVE? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-06-25 17:34 +0000
Re: Implementation of LEAVE? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-06-26 12:14 -0500
Re: Implementation of LEAVE? hughaguilar96@gmail.com - 2016-06-26 16:36 -0700
Re: Implementation of LEAVE? hughaguilar96@gmail.com - 2016-06-26 17:57 -0700
Re: Implementation of LEAVE? Alex McDonald <alex@rivadpm.com> - 2016-06-27 14:16 +0100
Re: Implementation of LEAVE? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-06-27 16:12 +0000
Re: Implementation of LEAVE? Alex McDonald <alex@rivadpm.com> - 2016-06-27 22:31 +0100
Re: Implementation of LEAVE? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-06-27 14:21 +0000
Re: Implementation of LEAVE? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-06-27 11:05 -0500
Re: Implementation of LEAVE? JennyB <jennybrien@googlemail.com> - 2016-06-25 03:49 -0700
Re: Implementation of LEAVE? JennyB <jennybrien@googlemail.com> - 2016-06-24 08:45 -0700
Re: Implementation of LEAVE? JennyB <jennybrien@googlemail.com> - 2016-06-24 02:33 -0700
Re: Implementation of LEAVE? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-06-24 16:23 +0000
Re: Implementation of LEAVE? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-06-23 11:43 +0000
Re: Implementation of LEAVE? alexinbeijing@gmail.com - 2016-06-24 11:41 -0700
Re: Implementation of LEAVE? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-06-25 05:18 +0000
Re: Implementation of LEAVE? Brad Eckert <hwfwguy@gmail.com> - 2016-06-27 17:45 -0700
Re: Implementation of LEAVE? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-06-28 06:14 +0000
Re: Implementation of LEAVE? Brad Eckert <hwfwguy@gmail.com> - 2016-06-24 15:30 -0700
Re: Implementation of LEAVE? minforth@arcor.de - 2016-06-24 04:36 -0700
Re: Implementation of LEAVE? Mark Wills <markwills1970@gmail.com> - 2016-06-25 07:51 -0700
Re: Implementation of LEAVE? Coos Haak <chforth@hccnet.nl> - 2016-06-26 00:37 +0200
Re: Implementation of LEAVE? Mark Wills <markwills1970@gmail.com> - 2016-06-25 08:29 -0700
Re: Implementation of LEAVE? "HAA" <someone@microsoft.com> - 2016-06-26 15:31 +1000
Re: Implementation of LEAVE? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-06-26 10:16 +0000
Re: Implementation of LEAVE? "HAA" <someone@microsoft.com> - 2016-06-27 22:38 +1000
Re: Implementation of LEAVE? Alex Dowad <alexinbeijing@gmail.com> - 2016-06-26 13:53 -0700
csiph-web