Re: catch and eval
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.tcl archive

Re: catch and eval

From: Bryan Oakley <oakley@bardo.clearlight.com>
Date: Tue Dec 20 2005 - 21:35:34 CET

Himesh P. wrote:
> if [catch {puts $args} msg] { ... }
>
> gives me:
> (bin) 3 % foo "hi there"
> {hi there}
>
> if [catch {eval puts $args} msg] { ... }
> (bin) 7 % foo "hi there"
> hi there
>
> I realize eval is redundant, but the reason I used it is the curly
> braces that result, which caused me to run into the problem with catch.

The reason the curly braces appear is because $args is a list. If you
want to convert it to a string without curly braces it is (arguably)
better to do so explicitly rather than to rely on a side effect of eval:

     if {[catch {puts [join $args " "]}]} ...
Received on Fri Dec 23 19:02:37 2005