Exception style (was: Tcl/Tk 8.5a4 released)



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.
.