[SLOF] [PATCH] slof/engine.in: remove the "COMPILE" keyword

Segher Boessenkool segher at kernel.crashing.org
Thu Feb 1 03:11:05 AEDT 2024


On Tue, Jan 23, 2024 at 04:11:09PM +0530, Kautuk Consul wrote:
> So, 2 questions for Segher:
> i)	Can we use the standard DOTICK DOCOL COMPILE, and DOTICK SEMICOLON
> COMPILE, method for +COMP and -COMP respectively ? That seems to be more
> efficient as that doesn't use the return stack.

No, the standard requires the word COMPILE to exist.  It is a standard
Forth word, historical (it isn't part of ANS Forth).

In compiled code of course you will see what is compiled by the
compiler, not the source code.  COMPILE is compilation-only word, so you
do not see it in command scripts even.  In very old Forth
implementations it would be simply compiled like anything, so
"COMPILE DUP" would end up as two cells with the addresses of "COMPILE"
and "DUP" in the generated (indirect-threaded or direct-threaded) code,
and at runtime the COMPILE would get the next cell and plop it into the
currently compiling definition.  But not anymore: this cannot work for
more modern implementations, better optimising implementations; we now
have POSTPONE instead of COMPILE (and [COMPILE] , in ye olde days the
programmer had to know which words were immediate words).

engine.in is compiled code (well almost, not yet fixed to any absolute
address and stuff).

> ii)	Instead of EXIT used in -COMP can we use SEMICOLON instead to
> compile into HERE ? That seems to be in line with how the col() macro
> is defined and gives better information to the reader of this code that
> the compiler is trying to generate the same "DOCOL <forth words> SEMICOLON"
> format of defining subroutines.

I have no idea what you mean, sorry.  Propose a patch, and say why that
would be better?


Segher


More information about the SLOF mailing list