D's SwitchStatement accepts statements with ridiculous semantics

H. S. Teoh hsteoh at quickfur.ath.cx
Fri Sep 29 16:18:50 UTC 2017


On Fri, Sep 29, 2017 at 12:32:02PM +0200, Timon Gehr via Digitalmars-d wrote:
[...]
> It is very likely that this part of the grammar was deliberately
> copied from C. It's also consistent with how all other control flow
> constructs are parsed.

I believe one of the reasons the grammar was written this way was to
allow Duff's device in D.  Personally, I don't care much for it -- an
optimizing compiler ought to be able to generate the best code without
requiring the programmer to explicitly write Duff's device.  Though
Walter did indicate that dmd's optimizer is lacking in the loop
unrolling department.


T

-- 
It is not the employer who pays the wages. Employers only handle the money. It is the customer who pays the wages. -- Henry Ford


More information about the Digitalmars-d mailing list