request switch statement with common block

JS js.mdnq at gmail.com
Sat Aug 3 12:51:32 PDT 2013


On Saturday, 3 August 2013 at 19:10:19 UTC, Andre Artus wrote:
> On Saturday, 3 August 2013 at 18:56:47 UTC, JS wrote:
>> On Saturday, 3 August 2013 at 17:45:11 UTC, w0rp wrote:
>>> I can see you saving a little bit of typing with this, but 
>>> it's
>>> not worth it.
>>
>>
>> Um, it can actually save a lot of type and errors.
>>
>> having two places to change is very error prone.
>>
>> if (cond) { }
>> switch(cond)
>>
>> If the condition is complex and one forgets it is the same 
>> condition then only changing one block will cause bugs.
>>
>> It is not a hard feature to have AND it is worth it because it 
>> is a near zero complex compiler implementation.
>>
>> So, depending on how you define "not worth it", which I take 
>> "I'm too lazy to implement it", you could be correct.
>
> If the implementation is so obviously trivial why don't you 
> implement a proof of concept? The compiler is open source after 
> all.

because I have better things to do and there is an extreme 
likelihood it won't be accepted.

> People routinely underestimate the ripple effect that adding 
> 'trivial' extensions to a language can have on a language.

Um, and people routinely don't think hard enough about the 
problem to realize the feature is an orthogonal semantic that has 
no bearing on anything but what it does.

Why do I know this?

Because the feature is short hand notation that can be directly 
implemented the long way. If the long way doesn't have problems, 
then the short way does not have any problems(except if your 
implementation is bad, but that's not the fault of the short way).

I can write a preprocessor to do the things I need to do. I have 
done it before. The problem is it is hard to make such features 
robust without some grammatical context such as an ast.



More information about the Digitalmars-d mailing list