switch()

Steven Schveighoffer schveiguy at yahoo.com
Thu Feb 20 06:56:38 PST 2014


On Tue, 18 Feb 2014 17:37:43 -0500, Walter Bright  
<newshound2 at digitalmars.com> wrote:

> On 2/18/2014 8:38 AM, Steven Schveighoffer wrote:
>> My point though, is that the change to require default gains you  
>> nothing except
>> annoyed programmers. Why put it in?
>
> This was fiercely debated at length and settled here years ago. It isn't  
> going to change.

I thought it was a more recent change than years ago. When was the change  
made? Looking it up, looks like 2011. That was a long time ago, longer  
than I thought.

>> The comparison I AM making is that we are implementation a requirement  
>> that will
>> not achieve the behavior goal it sets out to achieve.
>
> It's been this way for years now, if there was emergent bad behavior, it  
> would be obvious by now. But I haven't heard any reports of such.

Emergent bad behavior is not the result I would expect. Most likely,  
leaving out the default case was not an error. If this fixed a "bug" that  
didn't exist, the fact that bad behavior didn't result isn't really  
informative.

What I really would be curious about is if in most D code, you see a lot  
more default: break; than default: assert(0);

In any case, I am not vehemently against requiring a default case, it's  
not terrible to put in default: break; I just find it somewhat puzzling  
that it's required.

-Steve


More information about the Digitalmars-d mailing list