The Artima Developer Community
Sponsored Link

.NET Buzz Forum
What's with those "break" statements?

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Eric Gunnerson

Posts: 1006
Nickname: ericgu
Registered: Aug, 2003

Eric Gunnerson is a program manager on the Visual C# team
What's with those "break" statements? Posted: Nov 12, 2004 4:35 PM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Eric Gunnerson.
Original Post: What's with those "break" statements?
Feed Title: Eric Gunnerson's C# Compendium
Feed URL: /msdnerror.htm?aspxerrorpath=/ericgu/Rss.aspx
Feed Description: Eric comments on C#, programming and dotnet in general, and the aerodynamic characteristics of the red-nosed flying squirrel of the Lesser Antilles
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Eric Gunnerson
Latest Posts From Eric Gunnerson's C# Compendium

Advertisement

One comment from my recent post was big enough to handle separately...

Thomas wrote:

I'll second the break statement. Why is it really necessary? Haven't you guys got enough feedback to acknowledge that wasn't the brightest move? You say it is there to please the C++ developers, because they are your main target.

  1. The C++ developers thought they were smart. You just stated they aren't, as you don't believe they can adjust to the new rules.
  2. You insult all the other programmers, as they are not the target. At least not more than a minor target.
  3. Finally, you insult everyone not on the C# team, as you think you are smarter than us. You could just have made the break statement optional.

When we were designing the language, we decided we wanted to do something about the fall-through behavior of C++. In my years of writing C and C++ code, I had come across several cases where the behavior was troublesome. I believe that experience was widely shared among the language designers.

So, we decided that any fallthrough would have to be explicit through a "goto" statement, which has the nice byproduct that cases can be re-ordered without a problem. We then had to decided whether "break" would be required, or whether it would be optional.

We decided to make it explicit to make it easier for developers who write in more than one language - which our research data shows to be a significant percentage of developers. The question is not whether we think C# developers are smart enough to learn the new rules - the question is whether we wanted to force developers to remember two different kinds of switch statements so that they could save 7 characters of typing. Changing the syntax there would have been a gratuitious change. With this behavior, while there are different rules for *writing* switch statements, reading them is the same across languages.

Having written code both in C# and C++ recently, I'm happy with the choice that we made. There are enough differences between the two languages that I'm happy not to have another to deal with.

I admit that we haven't done the best job at explaining our language rationale. But now that you know the rationale behind this decision, do you think it was the right one?

Read: What's with those "break" statements?

Topic: Radio Silence and Halo 2 Previous Topic   Next Topic Topic: Veterans Day

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use