I've never had a case where I needed to use the construct you describe and I can think of ways to get the same effect without the potential for problems. As a result, I think you have set your self a really hard task of arguing that it has more advantages than problems.
The point I'm trying to make is that a trivial translation to an if else
chain is not the only realistic choice. What you propose is non trivial and,
in a few minuets of thinking I've already thought of a number of ways it
breaks the expected semantics of the classic switch statement (it can end
up with worse than linear cost for one) and a small slew of potential issues.
Personably, I don't see the value in it. It sits on an odd kind of place
where it has a statically defined number of options but they are dynamically
defined as to what they are. I rather suspect that in most cases both of
these will be static or dynamic.
- Re: switch case for constants-only? Rainer Deyke
- Re: switch case for constants-only? Nick Sabalausky
- Re: switch case for constants-on... Rainer Deyke
- Re: switch case for constants-only? Sean Kelly
- Re: switch case for constants-only? Nick Sabalausky
- Re: switch case for constants-only? div0
- Re: switch case for constants-only? BCS
- Re: switch case for constants-only? Nick Sabalausky
- Re: switch case for constants-only? BCS
- Re: switch case for constants-only? Nick Sabalausky
- Re: switch case for constants-on... BCS
- Re: switch case for constants-only? Don
- Re: switch case for constants-only? Ellery Newcomer
- People, and their irrational fear of string mixins downs