Catch form problem

Q&A's, tips, howto's
Locked
iNPRwANG
Posts: 32
Joined: Sun May 08, 2011 1:45 pm

Catch form problem

Post 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))

iNPRwANG
Posts: 32
Joined: Sun May 08, 2011 1:45 pm

Re: Catch form problem

Post by iNPRwANG »

Please close this subject, I known what's my mistake :)

Patrick
Posts: 7
Joined: Fri May 25, 2012 5:15 pm

Re: Catch form problem

Post by Patrick »

Would you mind posting the solution just for the record in case somebody else finds this topic while looking for it?

Locked