RE: [colorforth] forth taxonomy
- Subject: RE: [colorforth] forth taxonomy
- From: Mark Slicker <maslicke@xxxxxxxxxxx>
- Date: Thu, 7 Aug 2003 13:12:45 -0400 (EDT)
On Wed, 6 Aug 2003, Samuel Falvo wrote:
> > I'm curious how different Forths aproached this aspect. I'd
> > like to implement meta-compilation in colorForth which does not seem
> > obvious to me.
>
> For my Forth, I treat meta-compilation as a special case of target compilation.
> In short, I don't bother trying to "meta"-compile anything. I build a target
> compiler which simply targets the host machine.
>
> As far as actually how to write your meta-compiler, my approach is to write the
> source for your Forth environment in the ideal dialect of Forth, then write the
> appropriate words to make said source compile as you want it. Note: this will
> almost certainly mean redefining words (e.g., HERE becomes HHERE [host's HERE],
> etc).
>
> NOTE: Since ColorForth uses a look-up table for dispatching to various word
> handlers based on color, it should be easy to replace the default functionality
> of the various colors by simply swapping out the handler addresses in the jump
> table. Hence, it's actually much easier to write a target compiler in
> ColorForth than for other Forth systems; just as you would have FORTH and MACRO
> to switch the current vocabulary definitions go into, so you would have HOST
> and TARGET (or some similar names) to swap in the appropriate color look-up
> vectors.
HOST/TARGET is a nice idea. I built the beginings of a target compiler in
colorForth. It is pretty much as you describe.
With metacompilation you are not simply extending the internals, but
actually describing the internals in Forth, correct? I started down this
path, although I can't say it is 100% clear. I suppose ideally you want
this set of internals to run on either the target or host, then you can
load this as an application and run the compiler on itself to generate the
intial image. It seems you would need careful with addresses since the
compilation address is likely different from the execution address. This
part seems tricky.
>
> If I've confused, I apologize. I'll try to explain further in you're
> interested.
Yes I'm interested, please explain if it is not too much trouble.
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: colorforth-unsubscribe@xxxxxxxxxxxxxxxxxx
For additional commands, e-mail: colorforth-help@xxxxxxxxxxxxxxxxxx
Main web page - http://www.colorforth.com