Re: Tcl Switch case



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

.



Relevant Pages

  • Re: change of random state when pyc created??
    ... Realizing that that's the cause of the problem that's arbitrarily and ... explanation and did not assert a bug, ... not matter *then* there was a bug. ... I would have said the same thing: no, that's not safe. ...
    (comp.lang.python)
  • Re: Safe Printing (Revisited)
    ... I filed a bug report, but haven't heard back on it ... > "Jody Gelowitz" wrote in message ... >> Printing working over an Internet Zone. ... >> Based on what was mentioned from the previous thread titled "Safe ...
    (microsoft.public.dotnet.security)
  • Re: [SLE] SuSE 9.* and TFT screens
    ... This also happens with Windows when I forgot to switch to a safe mode ... resolution and frequency before setting up my new LCD monitor. ...
    (SuSE)
  • Re: Wiring a furnace to run off an extension cord.
    ... The suggestion I have seen is put a double pole double throw switch on the H and N wires and switch them to a male socket to which you attach an extension cord when necessary. ... just put a regular plug on the wires going to the furnace and ... It should be perfectly safe, but code is not always logical, and just because it is safe does not mean it is legal. ...
    (alt.home.repair)
  • Re: mounting a safe
    ... Drill one or more holes in the floor of the safe then use these holes for bolts anchored in the floor. ... to pass to/through the next slab etc? ... You can put a switch inside the door of the safe with hidden wires going to your 'silent holdup alarm' circuit. ...
    (alt.home.repair)