static switch

bearophile bearophileHUGS at lycos.com
Wed Mar 5 11:40:45 PST 2014


Andrei Alexandrescu:

> Doesn't enable anything.

Right, on the other hand a switch offers code more DRY compared 
to nested static ifs, and this part of the point of having a 
dynamic switch too. And the cognitive cost for a D programmer to 
remember what is a "static switch" is small (even if you 
inevitably need "static final switch" too if you create a "static 
switch"). I have never opened an enhancement request on this 
because the need for a static switch is not strong, but it's not 
zero.


> There'd be a ton more juice in a static foreach; it would 
> enable a lot of great idioms. We should pursue that instead.

> Probably worth a DIP. Other than that, we're a go.

So do you like to tag this issue as pre-approved? (The gist of 
this ER is that even an arbitrarily partial implementation of a 
static foreach is better than having none at all):
https://d.puremagic.com/issues/show_bug.cgi?id=4085

Bye,
bearophile


More information about the Digitalmars-d mailing list