>>>>> "John" == John Earnest <[email protected]> writes:

> Howdy folks, Factor, PostScript and a few other stack-oriented
> languages have literal syntax for blocks of code- Factor calls these
> "quotations". I've been puzzling over how I might go about building a
> similar facility in GForth. I'd like to define { and } to delimit an
> inline word and leave an XT on the stack. So, for example, if I
> executed a word like:

>     : test   54 { 27 . } execute . ;

> It would simply print "27 54". Here's my first try at { and } :

>     : {   postpone ahead noname create latestxt ; immediate     : }  
> postpone exit >r postpone then r> postpone literal ; immediate

After some changes, this seems to actually work:

: { postpone ahead :noname ; immediate
: } postpone ; >R ] postpone then R> postpone literal  ; immediate

: test  54 { 27 . } execute . ;

The main problem with your approach is that 'create latestxt' does not
start a callable section of forth code.  Also note that gforth is not a
simple indirect threaded forth, so many naive assumptions about how code
can be generated/patched won't hold (you may use gforth-itc if you need
that anyways).

cheers,

David
-- 
GnuPG public key: http://dvdkhlng.users.sourceforge.net/dk.gpg
Fingerprint: B17A DC95 D293 657B 4205  D016 7DEF 5323 C174 7D40

Attachment: pgpsqy1mcUzDJ.pgp
Description: PGP signature

Reply via email to