Примечание: EVALUATE
интерпретирует (переводит) строку. Это означает, что в состоянии компиляции ваш «Hello» будет скомпилирован . Например:
: foo s" hello" evaluate ;
: [foo] foo ; immediate
: hello ." something" ;
: bar [foo] ; \ "hello" will be compiled into bar
bar \ will execute hello
Другой способ заключается в использовании SEARCH-WORDLIST
или FIND-NAME
слов, например:
s" hello" find-name dup ?nf name> execute
Где
find-name ( c-addr u -- nt|0 ) \ returns a name token nt or 0
?nf ( nt|0 -- ) \ throws an exception on zero, i.e. not found
name> ( nt -- xt )
Последние два можно определить в Gforth как
: ?nf ( x|0 -- ) if exit then -13 throw ;
: name> ( nt -- xt|0 )
dup name>interpret swap name>compile drop over = if exit then drop 0
;