home .. forth .. colorforth mail list archive ..

Re: [colorforth] DOES> How is colorForth different from other Forths?


Frédéric DUBOIS wrote:
De : Chuck Moore [mailto:chipchuck@xxxxxxxxxxxxxx]

Trade-offs were different with threaded code. But when compiling native
code, fewer syntatical constructs seems better. It's nice to say that

Why?

I can't speak for Chuck, but I can say something. With threaded code you get a real hardware advantage from DOES> . It does some magic that you can't do with straight Forth code. If you try to write DOES> in high-level Forth code that doesn't use DOES> you get something obviously inefficient and clunky. If it's clunky and inefficient with native code, why do it?

colorForth source has a 1-1 correspondance with object code. If several
syntaxes generated the same code, it would be a many-1 correspondance.

How much do you value this correspondance? Is there some benefits to use it
in bytecode implementations for example?

I'm not clear what Chuck will use in place of DOES> . There might be something worth doing. When you make a macro it does a series of instructions from one name. Traditional DOES> is more complicated than that, I don't think you can write it so it just compiles a short series of instructions. But you might make macros that do <literal> <command>. That's the final result that DOES> gives you, except that the literal is something special, a particular address. It doesn't have to be an offset from HERE , it could be anything that's useful to you, the address was just the only way that DOES> did it. So if you do that particular style of macro often enough it might be worth making a macro to make that kind of macro. You might have something like

( x ) ' <command> DOIT <name>

I don't know whether that's worth doing. I sure don't know whether it's worth doing it more like DOES>.

' <command> MAKE-DO MY-PARENT
( x ) MY-PARENT MY-CHILD

Now you have a hierarchy of macros, the MAKE-DO word, a different MY-PARENT variation for each command, and then a different child for each address etc. Do you need that many words? A little more typing gives you every final result with just the one DOIT word plus a name for each child. And for just a : and a ; and a couple of color changes you get that final result with no scaffolding at all.

You'll have to find out by experience how many extra words are worth having.

Best wishes.



---------------------------------------------------------------------
To unsubscribe, e-mail: colorforth-unsubscribe@xxxxxxxxxxxxxxxxxx
For additional commands, e-mail: colorforth-help@xxxxxxxxxxxxxxxxxx
Main web page - http://www.colorforth.com