[comp.lang.forth] Bill's DOES

wmb@MITCH.ENG.SUN.COM (08/10/90)

> I'm curious, would someone mind posting a quick run-down of the
> alternate syntax for Does> to which Mitch alluded?

By way of introduction, this alternate syntax is often called
"Bill's DOES", because it was proposed by Bill Ragsdale, and it
is a pun on  <BUILDS ... DOES>  which was the old name for what
is now CREATE ... DOES>

The basic idea is that the "action clause" is defined *before* the
defining word.  The following discussion does not use Ragsdale's names
(because I am away from my library right now and can't look it us),
but does capture the spirit.

Instead of         : CONSTANT   CREATE ,   DOES> @   ;
You would write    (:)  @  ;    : CONSTANT  CREATE ,  <DOES  ;

The word (:) creates an anonymous colon definition.  The cfa of that
definition is left on the stack where it may be later used by <DOES ;

Note that in the new syntax, there is no longer a partial colon definition
(in this case " @ ; ") embedded inside another colon definition.  It turns
out that "Bill's DOES" is a whole lot easier to metacompile than DOES> .
Another nice property is that the syntax lends itself easily to multiple-
code-field words (defining words whose children have more than one action,
i.e. objects).

	START-ACTIONS
	(:) @ EXECUTE  ;
	(:) !  ;
	END-ACTIONS
	: DEFER  CREATE 0 ,  <DOES  ;

Mitch

DAVID@PENNDRLS.BITNET (08/10/90)

Thanks Mitch.  It's nice to see that I'm not as dumb as I sometimes
think I am: what you described is pretty much what I came up with
when thinking the problem through.  Your comment about it being
easy to extend to multiple-CFA words brings up an unrelated question,
though: how is >BODY implemented in a FORTH that supports multiple
CFAs?

-- R. David Murray    (DAVID@PENNDRLS.BITNET, DAVID@PENNDRLS.UPENN.EDU)

wmb@MITCH.ENG.SUN.COM (Mitch Bradley) (08/18/90)

> _Why_ hasn't Ragsdale's idea [for a CREATE DOES> syntax with the
> DOES> part first] caught on?

Speculation:

1) People do not read the literature.
2) DOES> is sort of an advanced concept; many Forth users never
   master it.  Fewer still run into its limitations.
3) I can't recally ANYTHING that has ever caught on just because
   somebody wrote a paper about it.  Generally, a technique has to
   appear in a major implementation before it achieves widespread use.

Mitch