Andrei Alexandrescu Wrote: > Jason House wrote: > > Andrei Alexandrescu Wrote: > > > >> Jarrett Billingsley wrote: > >>> On Mon, May 18, 2009 at 1:46 PM, Andrei Alexandrescu > >>> <seewebsiteforem...@erdani.org> wrote: > >>> > >>>> Final switch works with enums and forces you to handle each and every > >>>> value > >>>> of the enum. Regular switch gets ranged cases by the syntax case a: .. > >>>> case > >>>> b: (I've always thought switch would be greatly helped by that). > >>> Kind of an odd syntax. Why not "case a .. b:"? Parsing issues? > >> It's consistency. Everywhere in the language a .. b implies b is > >> excluded. In a switch you want to include b. So I reflected that in the > >> syntax. In fact, I confess I'm more proud than I should be about that > >> little detail. > > > > Consistency??? > > > > While I can see where you're coming from, I still see plenty of > > inconsistencies. It's still a range (defined with .. too). Having slices > > and foreach use syntax a and meaning 1 but switch using syntax a' and > > meaning 2 kind of sucks. > > You'd have to squint real hard to see a range. A range is > > expr1 .. expr2 > > That code is > > case expr1: .. case expr2: > > I mean you can't tell me that as soon as ".." is within a mile it's a range. > > > Andrei
It's all a matter of perspective. I see both as begin .. end. That may be the same reason why I think addition when I see foo(bar()) + baz(37). The extra cruft is more or less ignored when figuring out the basics of what is going on.