Re: Tcl/Tk 8.5a4 released
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: Tcl/Tk 8.5a4 released

From: Michael Schlenker <schlenk@uni-oldenburg.de>
Date: Fri Apr 28 2006 - 20:21:27 CEST

pedietz@west.com schrieb:
>> * [TIP 215] Made [incr] auto-initialize.
>
> Isnt this also a POTENTIAL_INCOMPATIBILITY ??
>
> I have code that does:
>
> if { [catch {incr BOB($x)} ] } {
> set BOB($x) 1
> #do other things because we know this is the 1st occurence of $x
> lappend things $x
> }
>
>
> What if you added a flag instead ?
>
> incr -noerror BOB($x) 1

Adding a flag instead was discussed, see the appropriate messages in the
Tclcore mailing list and in the TIP itself.
http://www.tcl.tk/cgi-bin/tct/tip/215.html

Yes, this is a potential incompatibility.

You can work around it in your code by redefining incr to throw an error
with non-existing vars.

One reason to really check what you want to know and not some side
effects of another command. [info exists BOB($x)] would be safer.

One could change your code to this style:
if {1 == [incr BOB($x)]} {
...
}

Depending on the amount of non-existing to existing vars this may be
quite a bit faster too.

Michael
Received on Sun Apr 30 03:30:51 2006