Question about deferred words

33 views
Skip to first unread message

Craig Lindley

unread,
Nov 28, 2018, 12:59:39 PM11/28/18
to pforthdev
I am trying to dynamically resolve deferred words as follows:

defer PRINTWORD

: print1 ." print1" cr ;

: print2 ." print2" cr ;

: p1test
 
' print1 is PRINTWORD
  PRINTWORD
;

: p2test
  '
print2 is PRINTWORD
  PRINTWORD
;


So when I call p1test the deferred word should be resolved and when PRINTWORD is called, print1 should print "print1". Unfortunately what I get is:

> p1test ' could not find Stack<10>
THROW code = -13
Undefined word!




Helmut Eller

unread,
Nov 28, 2018, 1:27:35 PM11/28/18
to Craig Lindley, pforthdev
You probably want to use ['] instead of '. ['] reads the name at
compile time, while ' reads the name at runtime.

Helmut

Craig Lindley

unread,
Nov 28, 2018, 1:40:31 PM11/28/18
to pforthdev
I figured this out. Instead of using tick, I must use ['] and then things work
Sorry for the noise
Reply all
Reply to author
Forward
0 new messages