Scott LaPlante wrote:
>
> i know this is outside of the bounds of aolserver in particular,
> but i was wondering if you have any idea why this:
>
> set catchReturn \
>   [catch {
>     return "my return value"
>    } catchResult]
> puts "catch return is: $catchReturn"
> puts "script result is: $catchResult"
>
> spits out:
>
> catch return is: 2
> script result is: my return value
>
> ?? catch should return 0 if the script doesn't exit with an error, correct?
>
> not a stopping point, but mostly curious on the tcl implementation.

you are getting a 2 because you are doing a "return" inside the catch
you don't get a 0 because the catch code dud not run to completion.
you "returned" before it could complete all the way. hence the value 2
you get a value of "1" if the code threw an error of some kind.

below are some examples typed into a tclsh shell.
they should be enlightening..

-mike


% catch { foo boo }; # nonsense code - throws an error
1

% catch { break }
3

% catch { return }
2

% catch { continue }
4

% catch {set a b}
0

% catch {set a b; return }
2

Reply via email to