Switch-case made less buggy, now with PATCH!

Chad J chadjoan at __spam.is.bad__gmail.com
Sun Nov 22 16:02:45 PST 2009


Don wrote:
> Chad J wrote:
>>
>> Sorry I didn't know about Andrei's proposal.  Buried in the NG.
> 
> I'm surprised about that. It's what all the recent posts were based on!
> 

Now I'm confused.

http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=101110

The recent posts were in a thread that *I* started.

Andrei was the first one in on the action:

Andrei Alexandrescu wrote:
> Chad J wrote:
>> So, switch-case statements are a frequent source of nasty bugs.  Fixing
>> them (well) requires breaking backwards compatibility.
>>
>> Any chance this will happen for D2?
>>
>> (This is intended as more of a reminder and simple curiosity than a
>> discussion.)
>
> I wish very much that a transferring control flow statement (break,
> return, goto etc.) is required at the end of each case. Then, the rare
> case when you want to break through is easy to implement as goto case
> xxx; and all is good.
>
> Walter's answer to that has put me to silence for good. "But I use
> fall-through all the time!" I then knew the feature will never make it.
>
>
> Andrei

Agreeable words indeed, but not terribly detailed.  I have to imagine
you and I are looking at different things.

>>
>> Why didn't you just say that Andrei made another proposal and that
>> you're peeved I didn't use it?
> 
> I'm not peeved.
> 

"You've done a patch which completely ignores his proposal, and which
violates both. "

"completely ignores" and "violates".  Strong words.  Ya coulda fooled me.

There's nothing wrong with being peeved ;)

>>> The comment about the auto-generated code raises an aspect which hadn't
>>> been considered in the original proposal.
>>
>> I also don't get this argument against requiring code changes.  D2 will
>> break your code and is allowed to do so for the sake of progress and
>> long term good.  Everyone knows this.
> 
> Yes, but it still needs a good reason to break with C/C++/D1 in a way
> which increases language complexity.

Of course.

I think we disagree on what constitutes a good reason.

I'm all about reaping as many very long-term benefits as possible.
Breaking a lot of code for a little gain over a long time is totally
justified in my mind.  (And this is a relatively small code breakage.)
If D2 takes off, we might be stuck with it for many years.  I'm kinda
hoping D3 doesn't happen, at least not unless we have automatic D2->D3
converters and make the migration easy.  I hear python did this very
well.  But now I'm rambling, so I'll leave it at that.



More information about the Digitalmars-d mailing list