switch case for constants-only?
div0
div0 at users.sourceforge.net
Sat Dec 5 17:02:18 PST 2009
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Sean Kelly wrote:
>>
>> In fact, it's already semantically equivilent to that, except that x and y
>> are currently required to be known at compile-time.
>
> D allows duplicate case values? I thought this was a compile error.
It does; from the switch spec:
====
Case expressions must all evaluate to distinct values. Const or
immutable variables must all have different names. If they share a
value, the first case statement with that value gets control. There may
not be two or more default statements.
====
Which seems sensible and should apply to the runtime evaluated case
statements as well if that gets added.
Haven't tested that though to see if that is actually what happens.
- --
My enormous talent is exceeded only by my outrageous laziness.
http://www.ssTk.co.uk
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iD8DBQFLGwKaT9LetA9XoXwRAoAJAKDF2NucN7mcZOgPuleV+Q4HosyTkQCgh2GB
EL4RJGfZBK/2nC3iM0ySjWw=
=L2pb
-----END PGP SIGNATURE-----
More information about the Digitalmars-d
mailing list