Re: if else else
- From: Neil Madden <nem@xxxxxxxxxxxxx>
- Date: Tue, 30 Jan 2007 12:35:13 GMT
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?
Potential for confusion.
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.
I don't think I've ever needed this myself, but if I did want such a thing, I'd probably implement it this way:
interp alias {} once {} foreach _ _
Which you can then use in simple fashion:
once {
if {$conda} {
...
} elseif {$condb} {
...
} else {
break
}
common cleanup
}
-- Neil
.
- Follow-Ups:
- Re: if else else
- From: Uwe Klein
- Re: if else else
- References:
- if else else
- From: Fredderic
- if else else
- Prev by Date: Re: Tcl bytecode
- Next by Date: Re: Expect binary is too slow on solaris but works fine on linux
- Previous by thread: Re: if else else
- Next by thread: Re: if else else
- Index(es):
Relevant Pages
|