[Submission] D Slices

Timon Gehr timon.gehr at gmx.ch
Tue May 31 11:36:50 PDT 2011


eles wrote:
> == Quote from Andrei Alexandrescu (SeeWebsiteForEmail at erdani.org)'s
> article
> > On 5/31/11 11:10 AM, eles wrote:
> > > I hope some day someone would not have to write a paper like
> http://
> > > drdobbs.com/blogs/cpp/228701625 but targetting... D's biggest
> mistake
> > > was to use open-limit on the right.
> > I sure wish that were the biggest mistake! :o)
> > Andrei
>
> Maybe you are right and there are others, too.
>
> Is off-topic, but I won't understand why D did not choose to
> explicitly declare intentions of "break" or "fall" after branches in
> switch statements (while dropping implicit "fall").
>
> It won't break existing or inherited (from C) code. It will just
> signal that it is illegal and force the programmer to revise it and
> to make sure it behaves as intended.

In my understanding, you use switch if you want fall through somewhere and if()
else if() else ... otherwise. (or you remember to break properly)

Yes, it can cause bugs. The other possibility would be to add excessive verbosity.
(Have a look into the Eiffel programming language.)

I am happy with how Ds switch works, but I understand your concerns too.

Timon


More information about the Digitalmars-d mailing list