Re: Exception style (was: Tcl/Tk 8.5a4 released)
- From: "Wojciech Kocjan" <hceicjow.backward@xxxxxxxxxx>
- Date: Sat, 29 Apr 2006 19:26:19 +0200
On Fri, 28 Apr 2006 22:07:53 +0200, Cameron Laird <claird@xxxxxxxxx> wrote:
In article <4bf4ouF11e870U1@xxxxxxxxxxxxxx>,
Michael Schlenker <schlenk@xxxxxxxxxxxxxxxx> wrote:
.
[little sympathy for cer-
tain legacy maintainers]
.
.
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.
.
.
There's a real question here whose answer I certainly don't know.
For decades, I, too, have not only said, "well, you can check what
you *really* want ...", but have advocated doing so as the clearer
solution. On alternate days, though, I'm sympathetic with the
argument that what one really wants in this situation is to
increment the variable, and that anything else *deserves* to be
coded as an exception.
I agree. One other condition is where someone accidentally mistypes a variable. Currently he/she would get an error and would realize his/her mistake.
The new non-error solution is error prone, because someone may not realize that this variable does not exist or is incorrectly referenced - and I can imagine [upvar]/[uplevel] related situations where this may not be easily traceable.
So: I'm uncertain whether your "info exists ..." is truly safer.
I agree. Although Tcl itself is singlethreaded in context of each variable, I can imagine variables being linked to an SQL database, where [info exists] may execute some SQL and [incr] will definitely execute read traces and write traces. Sure, it is a complex scenario, but tcldb's config does that and I personally use it quite often for counters.
I am for having a -nocomplain (or any other name) switch :)
--
WK
.
- Follow-Ups:
- Re: Exception style
- From: Darren New
- Re: Exception style
- References:
- Tcl/Tk 8.5a4 released
- From: Don Porter
- Re: Tcl/Tk 8.5a4 released
- From: pedietz
- Re: Tcl/Tk 8.5a4 released
- From: Michael Schlenker
- Exception style (was: Tcl/Tk 8.5a4 released)
- From: Cameron Laird
- Tcl/Tk 8.5a4 released
- Prev by Date: Re: Tcl/Tk 8.4.13 released
- Next by Date: Re: Tcl/Tk 8.4.13 released
- Previous by thread: Exception style (was: Tcl/Tk 8.5a4 released)
- Next by thread: Re: Exception style
- Index(es):