C# 4.0
-
Actually, foreach is needed. Without foreach, you can't guarantee that the Enumerable pattern is followed. You don't expect developers to consistently follow the pattern using a for or while loop.
Sunny Ahuwanya "The beauty of the desert is that it hides a well somewhere" -- Antoine de Saint Exupéry
Surely without foreach you'd just be in the same position as Java was (pre v1.5?) where you have to make a call to getIterator() and then loop through that. It's much more unfriendly than foreach but it still does the same thing Russ
-
I saw someone comment on that on another forum. Basically, you'd have something like this (using his sample syntax):
int? x = Company?.Person["Bob"]?.Age;
If Company or Company.Person["Bob"] were null, then x would be set to null, rather than getting an exception. I likes.
Kyosa Jamie Nordmeyer - Taekwondo Yi (2nd) Dan Portland, Oregon, USA
hm.. sexy!
-
I bet 99% of you disagree with this one! I would like to see multiple inheritance and full operator overloading available in C#.
Ditto! While I seldom use multiple inheritance, it still would be great to have it availble for those times that I do.
Rocky <>< Recent Blog Post: Netflix Gets Starz!
-
So now that C# 4.0 is being talked about, I was wondering what people thought would be good additions to the language. Sorry if this is a repost, but I went through several pages, and didn't see anything, so... What I'd frankly love to see would be tuples. Rather than having to use multiple 'out' parameters, you'd just return multiple values:
public int,int MinMax(int[] numbers)
{
int min, max;
// Code to calculate min/maxreturn min, max;
}What do you think? What would be good for the next version?
Kyosa Jamie Nordmeyer - Taekwondo Yi (2nd) Dan Portland, Oregon, USA
Yep, that would be handy!
Rocky <>< Recent Blog Post: Netflix Gets Starz!
-
So now that C# 4.0 is being talked about, I was wondering what people thought would be good additions to the language. Sorry if this is a repost, but I went through several pages, and didn't see anything, so... What I'd frankly love to see would be tuples. Rather than having to use multiple 'out' parameters, you'd just return multiple values:
public int,int MinMax(int[] numbers)
{
int min, max;
// Code to calculate min/maxreturn min, max;
}What do you think? What would be good for the next version?
Kyosa Jamie Nordmeyer - Taekwondo Yi (2nd) Dan Portland, Oregon, USA
How about a way to check against all values in an array or enumerabale at once with perhaps the keyword 'any' like below.
int[] supportedValues = new int[] { 3, 4, 5 }
int x = 4;if (x == any supportedValues)
{
// Do something.
}Instead of:
int[] supportedValues = new int[] { 3, 4, 5 }
int x = 4;
bool xIsSupported = false;foreach (int value in supportedValues)
{
if (x == value)
xIsSupported = true;
}if (xIsSupported)
{
// Do something.
}Good idea?
-
So now that C# 4.0 is being talked about, I was wondering what people thought would be good additions to the language. Sorry if this is a repost, but I went through several pages, and didn't see anything, so... What I'd frankly love to see would be tuples. Rather than having to use multiple 'out' parameters, you'd just return multiple values:
public int,int MinMax(int[] numbers)
{
int min, max;
// Code to calculate min/maxreturn min, max;
}What do you think? What would be good for the next version?
Kyosa Jamie Nordmeyer - Taekwondo Yi (2nd) Dan Portland, Oregon, USA
Can anyone say partial properties? Being able to add attributes to properties created in generated code would be awesome (using a the MetadataType approach is such an ugly hack). I would also love to be able to add extension methods to a static class. I know everyone has wanted to add some functionality to Membership or Math.
-
So now that C# 4.0 is being talked about, I was wondering what people thought would be good additions to the language. Sorry if this is a repost, but I went through several pages, and didn't see anything, so... What I'd frankly love to see would be tuples. Rather than having to use multiple 'out' parameters, you'd just return multiple values:
public int,int MinMax(int[] numbers)
{
int min, max;
// Code to calculate min/maxreturn min, max;
}What do you think? What would be good for the next version?
Kyosa Jamie Nordmeyer - Taekwondo Yi (2nd) Dan Portland, Oregon, USA
What's wrong with out parameters?
-
Christian Graus wrote:
I'd love to see a const keyword on parameters to methods
Seems to me they could use the readonly keyword for this instead of introducing a new keyword. EDIT: :doh: const is already a keyword in C#. Shows you how rusty my C# is already... I'm not really up on compiler writing, so I'm not sure how hard this would be to implement in C#. The compiler would have to make sure that read-only properties/methods are called on readonly/const parameters. That may be nontrivial.
Shame neither of them act as a kind of write-once property (other than readonly when set in a constructor) so you can't have constant DateTimes and things.
-
MrPlankton wrote:
well then how about a void functA("a");
What if there's not such method?
You of course would write it, to handle that case.
MrPlankton
-
No it's not. I'm not asking how to solve anything. Simply a feature ideas request. And since you're the only one so far to suggest this is a programming question, you're the only one who thinks so.
Kyosa Jamie Nordmeyer - Taekwondo Yi (2nd) Dan Portland, Oregon, USA
-
Christian Graus wrote:
I can use const to tell a user when they can trust my code not to change their stuff.
erm, I don't see how that would work. I thought that const was more of a promise to yourself, or to implementors, not to users. Nothing prevents you from calling methods and setting fields, right? Ok, let me start it again. What is the const keyword supposed to do in parameters that has an effect outside the method?
"Computer Science is no more about computers than astronomy is about telescopes." - Edsger Dijkstra
Here's an example of what I think he's saying:
public void DoSomething(const Employee emp)
{
emp.Age = 32; // This would not compile.
}An object is passed by reference, so its properties are settable. You don't want to make the Age property read only, because normally, you want the consumer to be able to set it. But what if DoSomething was meant to be a final validation, and you didn't want anything in the object to change, because it could mess up state elsewhere? The const keyword would allow the developer to leave a property or field writable, but still be able to restrict when it could be written to.
Kyosa Jamie Nordmeyer - Taekwondo Yi (2nd) Dan Portland, Oregon, USA
-
You of course would write it, to handle that case.
MrPlankton
MrPlankton wrote:
You of course would write it, to handle that case.
I thought so. :) Then it's the same as with the current lack of optional method arguments - you have to write overloads and people complain. Now you would have to write void methods...
-
So now that C# 4.0 is being talked about, I was wondering what people thought would be good additions to the language. Sorry if this is a repost, but I went through several pages, and didn't see anything, so... What I'd frankly love to see would be tuples. Rather than having to use multiple 'out' parameters, you'd just return multiple values:
public int,int MinMax(int[] numbers)
{
int min, max;
// Code to calculate min/maxreturn min, max;
}What do you think? What would be good for the next version?
Kyosa Jamie Nordmeyer - Taekwondo Yi (2nd) Dan Portland, Oregon, USA
Free beer!
-
So now that C# 4.0 is being talked about, I was wondering what people thought would be good additions to the language. Sorry if this is a repost, but I went through several pages, and didn't see anything, so... What I'd frankly love to see would be tuples. Rather than having to use multiple 'out' parameters, you'd just return multiple values:
public int,int MinMax(int[] numbers)
{
int min, max;
// Code to calculate min/maxreturn min, max;
}What do you think? What would be good for the next version?
Kyosa Jamie Nordmeyer - Taekwondo Yi (2nd) Dan Portland, Oregon, USA
really interesting!
-
here here!
Kyosa Jamie Nordmeyer - Taekwondo Yi (2nd) Dan Portland, Oregon, USA
I strongly Agree! C# cut-offs from c++ were really too deep. cons keyword (both on parameters and members signatures) shoud be a MUST in any oo language. And what about the annoying lack of default in parameters? I'd like to see c# designers and gurus dealing with Office PIA... I'm sure they would have a private build of csc.exe with default parameters implementeed .... InvokeExcelStuff(theOnlyNeededParameter, null, null, null, null, null, null, null, null, null, null, null, null, null, null....)
-
So now that C# 4.0 is being talked about, I was wondering what people thought would be good additions to the language. Sorry if this is a repost, but I went through several pages, and didn't see anything, so... What I'd frankly love to see would be tuples. Rather than having to use multiple 'out' parameters, you'd just return multiple values:
public int,int MinMax(int[] numbers)
{
int min, max;
// Code to calculate min/maxreturn min, max;
}What do you think? What would be good for the next version?
Kyosa Jamie Nordmeyer - Taekwondo Yi (2nd) Dan Portland, Oregon, USA
-
So now that C# 4.0 is being talked about, I was wondering what people thought would be good additions to the language. Sorry if this is a repost, but I went through several pages, and didn't see anything, so... What I'd frankly love to see would be tuples. Rather than having to use multiple 'out' parameters, you'd just return multiple values:
public int,int MinMax(int[] numbers)
{
int min, max;
// Code to calculate min/maxreturn min, max;
}What do you think? What would be good for the next version?
Kyosa Jamie Nordmeyer - Taekwondo Yi (2nd) Dan Portland, Oregon, USA
-
MrPlankton wrote:
You of course would write it, to handle that case.
I thought so. :) Then it's the same as with the current lack of optional method arguments - you have to write overloads and people complain. Now you would have to write void methods...
Well you could cast it to the method you want even if there is no left side argument. (int)functA("stuff"); I'm just saying having the return type as part of the signiture would be nice to have from time to time.
MrPlankton
-
I'd love to see a const keyword on parameters to methods, and optional parameters. Both of which seem simple enough.
Christian Graus No longer a Microsoft MVP, but still happy to answer your questions.
What would you expect 'const' to do? Would it just be the programmers promise not to change the contents of the object (generating an error if an assignment was attempted)? Would it also be able to determine if a method call on the object changed the state of the object and generate an error? If const is accepted as a parameter keyword should it also be accepted as a method modifier? How would optional parameters differ from the current params keyword?
-
Well you could cast it to the method you want even if there is no left side argument. (int)functA("stuff"); I'm just saying having the return type as part of the signiture would be nice to have from time to time.
MrPlankton
MrPlankton wrote:
I'm just saying having the return type as part of the signiture would be nice to have from time to time
I know, I've been there myself. ;)