switch()
Manu
turkeyman at gmail.com
Sun Feb 16 08:13:03 PST 2014
On 17 February 2014 02:04, Chris Cain <clcain at uncg.edu> wrote:
> I think the main reason why switches work this way (and cannot/should not
> be changed) is because of one of the main design goals of D:
>
> http://dlang.org/overview.html
>
> #7: Where D code looks the same as C code, have it either behave the same
> or issue an error.
>
> The proposed changes would violate this, making existing C code change
> meaning silently (wrt implicit "break;" in particular).
>
Okay, but that doesn't address the range cases...
TBH, though, I agree that this is somewhat of a speed bump in D. I really
> rarely find myself using switches because of the same issues you mention.
> Unfortunately, without adding new syntax (which is also problematic for
> many reasons), such a thing cannot be fixed unless this goal is ignored.
>
I agree, I rarely use switch statements for the same reason. Deliberately
gimping a very useful control statement because it's shit in another
language (it really is!), seems like an extremely lame design goal to me.
switch could be so much more useful with these changes. I suspect most
people would avoid it much of the time for these reasons.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20140217/a19dd169/attachment-0001.html>
More information about the Digitalmars-d
mailing list