Re: Use of ';' in Forth Compiler



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.
.




Relevant Pages

  • Re: Building solution from the command line
    ... The solution gets built. ... Without the /out options I don't see compilation ... Is there a way to eliminate this prefix? ...
    (microsoft.public.vsnet.ide)
  • Re: [PATCH 02/21] ftrace.c: Add #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
    ... For other entries in say kernel/power, ... Allows some messages to not have a prefix at all ... Prefixes can vary inside a specific compilation unit ... for instance: acpi/apic typos were found/fixed ...
    (Linux-Kernel)
  • Re: Use of ; in Forth Compiler
    ... introduce a lookahead function. ... It's in LSE64 because I copied most of the design of LSE, not because I have any strong preference for it. ... I'm not interested in advocating it: the important difference between these dialects and other Forth dialects is compilation, ... Isn't the "historical feature of STOIC" pretty much a requirement for universal compilation? ...
    (comp.lang.forth)
  • Re: Run the Same Macro on Multiple Files
    ... which is all it needs for compilation. ... In JavaScript a "$" prefix is ... using the prefix to indicate data type). ... are the more serious issue (I've never had problems debugging type ...
    (microsoft.public.word.vba.general)
  • glut compiling problem
    ... I am trying to generate a glut window, however, I got some compilation ... it reports that: ... (many variables with X prefix in libglut.a) ...
    (comp.sys.hp.hpux)