dimanche 18 février 2018

USING IF Statement with FORTH produces "Interpreting a compile-only word"

I'm reading Starting Forth: 4. Decisions, Decisions.... I can run 42 42 = .

42 42 =  ok
42 42 = . -1  ok

Predictably, I get -1 which is two's compliment for true. However, if I push a 42 on the stack, and I run

42 .s
42 = IF ." foobar " THEN ; 

I would expect foobar to be outputted and it's not. Instead I get

    42 .s <1> 42  ok
    42 = IF ." foobar " THEN ;  
:2: Interpreting a compile-only word
    42 = >>>IF<<< ." foobar " THEN ; 
Backtrace:
$7F7539250B30 throw 

What's going on here?

Aucun commentaire:

Enregistrer un commentaire