Hey...
on p19 of "Introduction-to-newLISP" the following example is given:
(catch
(for (i 0 9)
(if (= i 5) (throw (string "i was " i)) )
(print i " ")
)
)
For some reason, the above does not print "i was 5", yet it does print the correct output. What am I missing? TIA...
--
dukester
catch and throw functions
Because "i was 5" is the value of the catch. It was not caught into any symbol, so there was no output. If you run it inside the repl, the entire expression will evaluate to "i was 5", but only the print statement will print things out.
Here is a more comprehensive tutorial I wrote on newLisp error handling and flow control using catch/throw:
http://artfulcode.nfshost.com/files/sim ... wlisp.html
Here is a more comprehensive tutorial I wrote on newLisp error handling and flow control using catch/throw:
http://artfulcode.nfshost.com/files/sim ... wlisp.html
Thanks for the URL. Nice article!! Helped a lot.Jeff wrote:Because "i was 5" is the value of the catch. It was not caught into any symbol, so there was no output. If you run it inside the repl, the entire expression will evaluate to "i was 5", but only the print statement will print things out.
Here is a more comprehensive tutorial I wrote on newLisp error handling and flow control using catch/throw:
http://artfulcode.nfshost.com/files/sim ... wlisp.html