What Language Features Do You Miss In C#?
-
So?
What you mean "So"?
goto
is justgoto
- so that statement that it's different is wrong. -
What you mean "So"?
goto
is justgoto
- so that statement that it's different is wrong.The concept is different.
-
I already knew about (and use) that type of fallthrough (but thanks for pointing it out anyway). I'm talking about a case (no pun intended) where you have an action to perform in two cases that requires some kind of setup in one of the cases but not the other.
switch(whichAction)
{
case Actions.ActionWithSetup:
DoSetup();
case Actions.Action:
DoAction();
break;
}In this example, in the one case, DoSetup is performed, followed by DoAction; in the other case only DoAction is performed. You can do this in C (and Java as I recall) but not in C#. I'm fine with the language not allowing the fallthrough to happen unintentionally but think there should be a keyword to allow it. For example:
switch(whichAction)
{
case Actions.ActionWithSetup:
DoSetup();
nobreak;
case Actions.Action:
DoAction();
break;
}I realize that in my example I could simply call DoAction in both cases (and that's what I would do, given the C# limitation); and I also understand that if I've got a block of code in the second case, I can break it out into a separate method and call that method in both cases (which again is what I would do); however, if it's a really small block of code, I don't necessarily want to create a new method for it or duplicate the code.
Yes, or what I frequently need:
assign default values ;
switch ( args.Length )
{
case 4 : parse parameter 4 ;
case 3 : parse parameter 3 ;
case 2 : parse parameter 2 ;
case 1 : parse parameter 1 ;
default : do something ;
} -
THROWS, as an optional declaration. I would like the following... public void myfunction(int x) throws ArgumentException, OverflowException { } And, Java needs the other form of throws too, which I'd like to see in C# public void myfunction(int x) throws NONE { } ... for methods which can't throw exceptions.
But you can't know what may be thrown by something it calls, so I don't see the point.
-
The concept is different.
What kind of concept are you talking about? That the labels are also used from the switch statement? That's certainly true but has nothing to do with
goto
. But you have been talking about thatgoto SOME_LABEL
is different thangoto case WHATEVER
- which is wrong. I think you have never seen any assembler output from C code or MSIL from C#, just look at my example which will give you an impression of the MSIL generated from a switch-case in C#. -
What kind of concept are you talking about? That the labels are also used from the switch statement? That's certainly true but has nothing to do with
goto
. But you have been talking about thatgoto SOME_LABEL
is different thangoto case WHATEVER
- which is wrong. I think you have never seen any assembler output from C code or MSIL from C#, just look at my example which will give you an impression of the MSIL generated from a switch-case in C#.Florian Rappl wrote:
goto SOME_LABEL
is different thangoto case WHATEVER
Yes, of course.
Florian Rappl wrote:
assembler output
Has no bearing on the discussion.
-
Yes! And gosub.
-------------- TTFN - Kent
ahhh, the route to HELL :laugh:
-
Because I have A Dangerous Mind[^] :-D
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
Espen Harlinn Principal Architect, Software - Goodtech Projects & Services AS Projects promoting programming in "natural language" are intrinsically doomed to fail. Edsger W.Dijkstra
-
Espen Harlinn Principal Architect, Software - Goodtech Projects & Services AS Projects promoting programming in "natural language" are intrinsically doomed to fail. Edsger W.Dijkstra
That's all I need[^] to know.
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
-
That's all I need[^] to know.
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
Good, I apologize[^] for the interruption ...
Espen Harlinn Principal Architect, Software - Goodtech Projects & Services AS Projects promoting programming in "natural language" are intrinsically doomed to fail. Edsger W.Dijkstra
-
Good, I apologize[^] for the interruption ...
Espen Harlinn Principal Architect, Software - Goodtech Projects & Services AS Projects promoting programming in "natural language" are intrinsically doomed to fail. Edsger W.Dijkstra
Why? What have you done?[^]
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
-
Sure, it's on another discussion site[^], but that doesn't mean we can't also discuss it here. Personally, while it certainly doesn't fit in the "missing" category, I see them moving it closer and closer to a hybrid C#/JavaScript language with each new version.
-------------- TTFN - Kent
-
Florian Rappl wrote:
goto SOME_LABEL
is different thangoto case WHATEVER
Yes, of course.
Florian Rappl wrote:
assembler output
Has no bearing on the discussion.
Either you are incapable of understanding this or you just do not want to get this. Your statement that there are 2 gotos is wrong. From a language point of view using goto with some (arbitrary) label and with a case label is equivalent.
-
But you can't know what may be thrown by something it calls, so I don't see the point.
In Java, every function must declare all potential throws. The compiler looks down the call stack and makes sure that exceptions are either handled or declared in the throws. If not, it's a compilation error. That annoys many Java developers, which is why I think the feature should be optional. If it was optional, we could generate a warning on unhandled exceptions. IT would not be a compilation error like it is in Java. This wouldn't totally prevent any problems, but it would give developers a way to be more explicit about what exceptions can happen. For library designers this would be very helpful.
-
The only good feature of Ruby! AWESOME :)
-
Why? What have you done?[^]
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
I'm afraid I've made a shot in the dark[^]
Espen Harlinn Principal Architect, Software - Goodtech Projects & Services AS Projects promoting programming in "natural language" are intrinsically doomed to fail. Edsger W.Dijkstra
-
I'm afraid I've made a shot in the dark[^]
Espen Harlinn Principal Architect, Software - Goodtech Projects & Services AS Projects promoting programming in "natural language" are intrinsically doomed to fail. Edsger W.Dijkstra
-
Oh, I'm so sorry - this must not be the The Last Time[^] we have such a jolly chat ...
Espen Harlinn Principal Architect, Software - Goodtech Projects & Services AS Projects promoting programming in "natural language" are intrinsically doomed to fail. Edsger W.Dijkstra
-
Oh, I'm so sorry - this must not be the The Last Time[^] we have such a jolly chat ...
Espen Harlinn Principal Architect, Software - Goodtech Projects & Services AS Projects promoting programming in "natural language" are intrinsically doomed to fail. Edsger W.Dijkstra
-
This is tuning into high drama - must our farewell [^] turn into such a bittersweet[^] afair. This is worse than A Demon's Fate[^], and now that peace is a Utopia[^] we will only be dealt a hand of sorrow[^] ...
Espen Harlinn Principal Architect, Software - Goodtech Projects & Services AS Projects promoting programming in "natural language" are intrinsically doomed to fail. Edsger W.Dijkstra