Jonah Thomas wrote:
> It isn't necessarily more complex for the compiler. But you have to
> think -- sometimes we want to parse strings and do something to them in
> midline.
>
> ... [ ' DUP ] LITERAL ....
>
> ... ['] DUP ....
>
> It isn't enough to tell the compiler to compile strings into the current
> word. There are other things to do with them.
>
> Print a string now. .(
> Print it later. ."
> Get an xt [']
> Get a character [CHAR]
> Maybe print and abort later ABORT"
> Ignore the string now (
> Etc.
>
> And then there's
>
> [ do-something-now ]
>
> Sometimes we want to execute anything right now, not later when the line
> executes, but now before the rest of the line has compiled.
>
> And .... POSTPONE IF .... sometimes we want to take a command that
> would normally happen now and make it happen later.
>
> You want to build all this into the compiler, and also make the compiler
> extensible? I have some doubts. It isn't trivial to always-compile and
> still do all the things we're used to doing. Somehow you have to decide
> what to give up.
>
> I think it's possible to get all the results you'd want that way. Like,
> you could have a system to start a new temporary line, and the new one
> executes before the old one. So you could do
>
> ['] FOO
>
> on a separate line and have it get compiled and then execute to compile
> FOO's xt as a literal in the previous definition, and then go back to
> compiling the unfinished definition. Each individual line would get
> compiled into the currently-unfinished code or compiled into its own
> routine that gets executed first, depending on which you tell that line
> to do. I started to implement this and got distracted with an income
> opportunity and haven't gotten back to it.
>
> But usually people who build always-compile systems accept less
> functionality.
No! But I personally will go for less *complexity*.
In LSE, the factors of the system's immediate words are, in effect, the
metaprogramming toolkit. You don't worry about POSTPONEing anything: you
just use its (non-immediate) factors. If you need to compute something
mid definition, you define a word for it and make that immediate.
There's no loss in functionality at all versus traditional Forth, only a
loss of cuteness. It's not like it would be difficult to put in POSTPONE
or [ and ], but why bother? Metaprogramming shouldn't be cute and
clever: it's usually a bad idea.
--
John Doty, Noqsi Aerospace, Ltd.
http://www.noqsi.com/
--
History teaches that logical consistency is neither sufficient nor
necessary to establish practical, real world truth. Those who attempt to
use logic for that purpose are abusing it.


|