Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #41947
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: ? operator in Forth |
| Date | 2015-09-11 05:16 +0000 |
| Organization | Institut fuer Computersprachen, Technische Universitaet Wien |
| Message-ID | <2015Sep11.071650@mips.complang.tuwien.ac.at> (permalink) |
| References | <1f86d832-a0bd-4d35-9587-0b81afe11035@googlegroups.com> <4121ada4-218e-4d14-9527-3a3d9bee5185@googlegroups.com> |
Mark Wills <markwills1970@gmail.com> writes:
>On Thursday, 10 September 2015 21:55:22 UTC+1, Mark Wills wrote:
>> Gauntlet: Can this be done in ANS?
>
>To answer my own question: Yes.
>
>This works on my system and is muuuuch neater:
>
>: ?? postpone if ' , ; immediate
>: :: postpone else ' , postpone then ; immediate
>
>How cool is Forth? :-)
As Elizabeth Rather writes, you would need COMPILE, instead of "," to
make this standard. And then it does not work as intended for
immediate words (whether they abort on ticking or not), so, as Hugh
Aguilar writes, EVALUATE is more appropriate here; and in this case it
is not problematic (unlike many other cases), because the string is
EVALUATEd exactly in the context in which it was written. So this
gives us:
: ?? postpone if ; immediate
: :: postpone else parse-name evaluate postpone then ; immediate
Example usage:
: foo [ 1e 2e ] ?? fliteral :: fliteral ; ok
Generated code:
see foo
: foo
IF 2.000000E0
ELSE 1.000000E0
THEN ; ok
Unlike the original, this supports not just 1 or more words between ??
and ::, but 0 or more words, and is simpler.
Overall, the only thing this gives us is that you do not need to type
THEN, but restricts you to having just one word after :: (whereas ? :
in C allows arbitrarily complex expressions).
- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2015: http://www.rigwit.co.uk/EuroForth2015/
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
? operator in Forth Mark Wills <markwills1970@gmail.com> - 2015-09-10 13:55 -0700
Re: ? operator in Forth Mark Wills <markwills1970@gmail.com> - 2015-09-10 14:16 -0700
Re: ? operator in Forth "Elizabeth D. Rather" <erather@forth.com> - 2015-09-10 11:58 -1000
Re: ? operator in Forth "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-09-11 01:30 -0400
Re: ? operator in Forth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-09-11 06:17 +0000
Re: ? operator in Forth julian.fondren@endurance.com - 2015-09-10 21:00 -0700
Re: ? operator in Forth hughaguilar96@gmail.com - 2015-09-10 21:20 -0700
Re: ? operator in Forth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-09-11 05:16 +0000
Re: ? operator in Forth humptydumpty <ouatubi@gmail.com> - 2015-09-12 01:11 -0700
Re: ? operator in Forth hughaguilar96@gmail.com - 2015-09-12 17:14 -0700
Re: ? operator in Forth humptydumpty <ouatubi@gmail.com> - 2015-09-13 02:18 -0700
Re: ? operator in Forth hughaguilar96@gmail.com - 2015-09-10 15:21 -0700
Re: ? operator in Forth "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-09-11 01:35 -0400
Re: ? operator in Forth humptydumpty <ouatubi@gmail.com> - 2015-09-10 22:58 -0700
Re: ? operator in Forth Hans Bezemer <the.beez.speaks@gmail.com> - 2015-09-11 18:48 +0200
Re: ? operator in Forth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-09-11 16:54 +0000
Re: ? operator in Forth hughaguilar96@gmail.com - 2015-09-11 21:32 -0700
Re: ? operator in Forth "WJ" <w_a_x_man@yahoo.com> - 2015-09-14 18:13 +0000
Re: ? operator in Forth "WJ" <w_a_x_man@yahoo.com> - 2015-09-14 18:32 +0000
Re: ? operator in Forth hughaguilar96@gmail.com - 2015-09-14 14:40 -0700
csiph-web