Re: if else else
- From: "Gerald W. Lester" <Gerald.Lester@xxxxxxx>
- Date: Tue, 30 Jan 2007 08:48:19 -0600
Fredderic wrote:
I know this idea will disturb many purists, but .....
I was wondering if there's any compelling reason not to allow a
secondary-else clause in the [if] command, apart from the fact that
it's generally just not done?
There have been numerous cases where I've had a "if ... elseif ...
elseif ... else" structure, where I've needed to do some cleanup if any
of the conditions match, but not in the "else" case. A secondary else
that matches if the regular one didn't (ie. if any of the regular
clauses DID match) would be handy for such cleanup (or in this case,
follow-up) code.
It wouldn't break anything, except good style. But it would come in
mighty handy... Just wondering how much of a flame I'd get for even
muttering such evil thoughts... ;)
That is *unusual*, one might even say *unique* -- I've never seen it in any language.
If you use another "keyword" other than else, it should be trivial to implement as a Tcl proc. You would want to read the man pages for if and uplevel before attempting to do the implementation.
--
+--------------------------------+---------------------------------------+
| Gerald W. Lester |
|"The man who fights for his ideals is the man who is alive." - Cervantes|
+------------------------------------------------------------------------+
.
- References:
- if else else
- From: Fredderic
- if else else
- Prev by Date: Re: I need an embeddable menu widget
- Next by Date: Re: problem compiling on SGI/IRIX
- Previous by thread: Re: if else else
- Next by thread: how to control the console on windows platform
- Index(es):
Relevant Pages
|