Another gotcha: using exit in a macro exits the caller not the macro
Alex Holden <[email protected]> Sun, 28 Nov 2004 21:35:42 +0000
| Newsgroups | gmane.comp.lang.forth.picforth |
|---|---|
| Message-ID | <[email protected]> |
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