[PicForth] Another gotcha: using exit in a macro exits the caller
not the macro
Alex Holden
alex at linuxhacker.org
Sun Nov 28 22:35:42 CET 2004
I just tripped over another gotcha (perhaps it's obvious to others but I
didn't expect it). When a word is a macro, exit operates within the
context of the word which calls the macro instead of in the context of
the macro. So in this example:
: sometest -1 ;
: dosomething ;
: dosomethingelse ;
macro
: test1 sometest if exit then dosomething ;
target
: test2 test1 dosomethingelse ;
When sometest returns true, instead of exiting from test1 (ie. jumping
to the next word in test2), picforth generates a return from test2 and
dosomethingelse never gets called.
--
------------ Alex Holden - http://www.linuxhacker.org ------------
If it doesn't work, you're not hitting it with a big enough hammer
More information about the PicForth
mailing list