Page 1 of 1

Catch form problem

Posted: Thu Jun 14, 2012 9:23 am
by iNPRwANG
The newLisp document said:
In the second syntax, catch evaluates the expression exp, stores the result in symbol, and returns true. If an error occurs during evaluation, catch returns nil and stores the error message in symbol. This form can be useful when errors are expected as a normal potential outcome of a function and are dealt with during program execution.
And in my code, I'd throwed a exception in catch of second syntax, why it always get "true" result instead of nil?

Code: Select all

(setq result nil)

(println (catch (dotimes (x 100) 
  (if (= x 50) (throw "fin"))) 'result))

Re: Catch form problem

Posted: Thu Jun 14, 2012 9:24 am
by iNPRwANG
Please close this subject, I known what's my mistake :)

Re: Catch form problem

Posted: Thu Jun 14, 2012 12:12 pm
by Patrick
Would you mind posting the solution just for the record in case somebody else finds this topic while looking for it?