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

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


Perhaps I should explain why colorForth doesn't have DOES>. (Of course, I
would spell  DOES>  as  does , just to simplify the syntax.)

It's actually the same reason it doesn't have CONSTANT. Generated code would
be the same. Including another syntax adds redundancy that I'm critical of
in other languages:
     10 constant ten
     : ten   10 ;
If you think about what code you might compile for  CONSTANT, you'll see
it's just:
     push number on stack
     return

: simple   constant does  @ push  swap 8 *  pop +  op, ;
   4140 simple adc,
   4000 simple and,

: simple   push  swap 8 *  pop +  op, ;
   : adc,  4140 simple ;
   : and,  4000 simple ;

Trade-offs were different with threaded code. But when compiling native
code, fewer syntatical constructs seems better. It's nice to say that
colorForth source has a 1-1 correspondance with object code. If several
syntaxes generated the same code, it would be a many-1 correspondance.


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