Re: Tcl Switch case
- From: Andreas Leitgeb <avl@xxxxxxxxxxxxxxxxxxxxxxxx>
- Date: 19 Feb 2008 11:37:46 GMT
tom.rmadilo <tom.rmadilo@xxxxxxxxx> wrote:
But it isn't hard to debug, that would be the first thing I notice,
that is the form without the '--' is not safe, you can't rely on the
value of $str.
It now *is* safe, when the new hassle-free simple form of switch is used.
Essentially what this fixes is poor programming style, that is,
someone who hasn't learned to use '--' will spend lots of time
figuring out their first bug.
Someone who wrote switch $val {...}
Will no longer have to search for a bug, because it now works
and is safe.
Someone else who wrote: (to mimic an "if" with regexp-comparison)
switch -regexp $var $pat {#body}
back then or now, will have a *really* hard time to find the bug,
because no error is necessarily thrown, depending on what $val,
$pat or the body really look like.
Okay. But I remember many times where I
go back and edit some code, backspacing over unneeded switches, etc.,
and maybe go a little too far. The usual result is an obvious syntax
error.
It's an utterly bad idea to *rely* on typos generating syntax-errors.
Not only would it require 100% coverage tests (including testing with
dangerous values), chances are already (even without this new one)
very high, that typos result in still legal but wrongly behaving code,
or code that behaves wrong only with carefully crafted values (entirely
impossible to cover 100% through testing).
.
- References:
- Tcl Switch case
- From: vinayak.mdesai@xxxxxxxxx
- Re: Tcl Switch case
- From: Andreas Leitgeb
- Re: Tcl Switch case
- From: Mark Janssen
- Re: Tcl Switch case
- From: WL
- Re: Tcl Switch case
- From: Bryan Oakley
- Re: Tcl Switch case
- From: Mark Janssen
- Re: Tcl Switch case
- From: Bryan Oakley
- Re: Tcl Switch case
- From: Andreas Leitgeb
- Re: Tcl Switch case
- From: tom.rmadilo
- Re: Tcl Switch case
- From: Mark Janssen
- Re: Tcl Switch case
- From: tom.rmadilo
- Tcl Switch case
- Prev by Date: recursive grab current - raise - update
- Next by Date: Re: recursive grab current - raise - update
- Previous by thread: Re: Tcl Switch case
- Next by thread: Re: Tcl Switch case
- Index(es):
Relevant Pages
|