switch()

Nick Sabalausky SeeWebsiteToContactMe at semitwist.com
Mon Feb 17 01:57:23 PST 2014


On 2/16/2014 10:39 PM, Manu wrote:
>
> Yeah, but when I suggest a..b, I suggest applying existing [) range rules,
> as would be expected.
>
> It doesn't make sense for enum keys, and I think the existing syntax is
> acceptable for [] usage with enum keys, but you're not always switching on
> enums.
> Perhaps supporting both would be useful, where a..b is [) as expected, and
> 'case A: .. case B:' is [] for use with enums?
>

There was a HUGE debate on all this back when the feature was first 
added, and every miniscule possibility and detail was thoroughly 
examined and argued ad nauseam.

IIRC, I was actually one the people not real happy with the syntax we 
have, but the thing is, it really isn't a big deal. It's just 
syntactical details on one particular construct. Yea, switch could be 
nicer looking, and it's not one of the nicer parts of D syntax, but the 
semantics are reasonably solid and that's the important part. The rest 
is just details and bikeshedding.

Personally, I would LOVE to see Nemerle's match statement/expression get 
into D, but other than that, out of all the tasks D faces, the switch 
syntax is pretty bottom-rung on both the importance and significance scales.



More information about the Digitalmars-d mailing list