"with" still sucks + removing features + adding features

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon May 18 11:00:40 PDT 2009


bearophile wrote:
> Andrei Alexandrescu:
>> About "with"... see above before I die of a heart attack.<
> 
> Qualified imports are safer. And it's better for: import foo; to
> import in the current namespace only the "foo" module name.

Yeah, so for the sake of a feature intended to save some minor typing, 
I'm thrilled to introduce a feature requiring me a ton of typing.

> Do you mean like this? final switch (...) {...}

Yah.

enum DeviceStatus { ready, busy, fail }
...
void process(DeviceStatus status) {
    final switch (status) {
    case DeviceStatus.ready:
       ...
    case DeviceStatus.busy:
       ...
    case DeviceStatus.fail:
       ...
    }
}

If you then add a new value for DeviceStatus, the final switch won't 
compile.

>> Regular switch gets ranged cases by the syntax case a: .. case b:
>> (I've always thought switch would be greatly helped by that).<
> 
> Isn't a syntax like the following better? case a .. b: Or (much)
> better still, isn't it better to give a built-in syntax to something
> like your iota(), removing the special syntax of ranged foreach and
> such ranged switch case?

I think it's important to give switch a crack on properly optimizing its 
code. And case a .. b I just explained to Jarrett.


Andrei



More information about the Digitalmars-d mailing list