Exception style (was: Tcl/Tk 8.5a4 released)
- From: claird@xxxxxxxxx (Cameron Laird)
- Date: Fri, 28 Apr 2006 20:07:53 GMT
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.
'Nother perspective: not only does catching exceptions out of,
let's say,
open $some_file
embody a certain style, but it reduces race conditions to which
if [file exists $some_file] {
# Perhaps other tests ...
set fp [open $some_file]
} else {
....
is subject.
So: I'm uncertain whether your "info exists ..." is truly safer.
.
- Follow-Ups:
- Re: Exception style (was: Tcl/Tk 8.5a4 released)
- From: Wojciech Kocjan
- Re: Exception style (was: Tcl/Tk 8.5a4 released)
- 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
- Tcl/Tk 8.5a4 released
- Prev by Date: Re: How to interpet Tcl/Tk stack information.
- Next by Date: Re: Tcl_Ungets help [long, technical]?
- Previous by thread: Re: Tcl/Tk 8.5a4 released
- Next by thread: Re: Exception style (was: Tcl/Tk 8.5a4 released)
- Index(es):