[Python-Dev] Switch statement - handling errors
Ka-Ping Yee
python-dev at zesty.ca
Wed Jun 28 05:21:20 CEST 2006
On Tue, 27 Jun 2006, Jim Jewett wrote:
> (Almost) everyone agrees that the case expressions SHOULD be run-time
> constants. The disagreements are largely over what to do when this
> gets violated.
I like your summary and understood most of it (options 1, 2, 3, 5, 6).
The only part i didn't understand was this:
> Bad Case Option (4) -- Ignore problems
> --------------------------------------
>
> This is for optimization; go ahead and ignore any problems you can.
> Maybe that branch will never be taken... Ironically, this is also
> largely school I, since it matches the if semantics.
Could you elaborate on what this means? Does "ignore any problems"
mean "even if a case value changes, pretend it didn't change"? But
that wouldn't match the 'if' semantics, so i'm not sure what you
had in mind.
> Bad Case Option (6) -- Undefined
> --------------------------------
[...]
> The down side is that people may start to count on the actual behavior
> anyhow; then (in practice) we might just have Bad Case Option (5)
> without documentation.
I agree with this last paragraph. Option 6 seems the most risky of all.
-- ?!ng
More information about the Python-Dev
mailing list