Re: Use of ';' in Forth Compiler
- From: "Jenny Brien" <jennifer@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 04 Jul 2005 12:27:38 +0100
On Sat, 02 Jul 2005 21:52:24 +0100, John Doty <jpd@xxxxxxxxxxxxxxxxxxxxxxx> wrote:
Bernd Paysan wrote:
John Doty wrote:
6 7 * theAnswer :constant
Parse, look up, and compile "6 7 *". Parse "theAnswer", look it up. It's
not an IMMEDIATE word, so hang on to it for now. Look up ":constant":
it's a SOONER word, so it gets executed immediately before theAnswer can
be compiled.I find this rather counter-productive. You say, LSE is simple. Now you introduce a lookahead function. What for? If you have
It's a historical feature of STOIC and its descendents. It has been thought by some that it makes the code more readable. It isn't hard to implement. It's in LSE64 because I copied most of the design of LSE, not because I have any strong preference for it. To me, it's a rather trivial and unimportant feature, but harmless. I'm not interested in advocating it: the important difference between these dialects and other Forth dialects is compilation, not lookahead.
For variables, I actually have two defining words in LSE64: LSE's postfix ":variable", and a new prefix "variables:" which was such an obvious combination of the existing factors that I couldn't resist. Now I often find myself using "variables:" even to define just one. So maybe I agree with you here, although I still find postfix ":" a skosh easier to read than prefix.
-jpd
Isn't the "historical feature of STOIC" pretty much a requirement for universal compilation?
The only way I can see to make variables: (or any Forth-like parsing prefix word) work is for it to be an IMMEDIATE word - which means, in many cases, that it cannot sensibly be used within a definition unless it is POSTPONED so that the parsing happens at run time. In STOIC, as I recall, any word prefixed with ' was pushed on the stack as a counted string, so you could do strange things like:
'Example : 'AVariable Variable 'ADefinition : ... AVariable ... ; ... ADefinition ... AVariable @ 'AVariable Forget ;
After 20 years, I'm not sure if that's valid STOIC code, but it gives a flavour of it. I gave up on STOIC when I failed to understand how it used the nested compilation trick to do the equivalent of CREATE DOES>.
--
The wise man knows what he knows - and he knows that he only knows what he knows.
.
- Follow-Ups:
- Re: Use of ';' in Forth Compiler
- From: John Doty
- Re: Use of ';' in Forth Compiler
- References:
- Re: Use of ';' in Forth Compiler
- From: PagCal
- Re: Use of ';' in Forth Compiler
- From: Elizabeth D Rather
- Re: Use of ';' in Forth Compiler
- From: Albert van der Horst
- Re: Use of ';' in Forth Compiler
- From: Elizabeth D Rather
- Re: Use of ';' in Forth Compiler
- From: John Doty
- Re: Use of ';' in Forth Compiler
- From: Andrew Haley
- Re: Use of ';' in Forth Compiler
- From: John Doty
- Re: Use of ';' in Forth Compiler
- From: Andrew Haley
- Re: Use of ';' in Forth Compiler
- From: John Doty
- Re: Use of ';' in Forth Compiler
- From: John Passaniti
- Re: Use of ';' in Forth Compiler
- From: John Doty
- Re: Use of ';' in Forth Compiler
- From: Bernd Paysan
- Re: Use of ';' in Forth Compiler
- From: John Doty
- Re: Use of ';' in Forth Compiler
- Prev by Date: Re: Questions about Forth for small micros
- Next by Date: Re: Questions about Forth for small micros
- Previous by thread: Re: Use of ';' in Forth Compiler
- Next by thread: Re: Use of ';' in Forth Compiler
- Index(es):
Relevant Pages
|