C# 4.0
-
here here!
Kyosa Jamie Nordmeyer - Taekwondo Yi (2nd) Dan Portland, Oregon, USA
I put these things to the C# team at least twice, and they appeared too stupid to understand why they were of value.
Christian Graus No longer a Microsoft MVP, but still happy to answer your questions.
-
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.
Christian Graus wrote:
optional parameters
Ditto - one of the few things that I prefer in VB.NET. Creating loads of overloads is a royal PITA.
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) -
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.
Good ideas. Have you suggested them to MS?
I didn't get any requirements for the signature
-
Jamie Nordmeyer wrote:
C# 4.0
I haven't heard anything about it.
Jamie Nordmeyer wrote:
return min, max;
That syntax wouldn't be a good choice, because of the comma operator. I would just return an array of int. Though the only place I do that is a routine that parses a string to get a latitude and longitude (doubles in this case).
PIEBALDconsult wrote:
That syntax wouldn't be a good choice, because of the comma operator.
It'd certainly take some work on the part of the parser developers at Microsoft, but it'd still be useful in my humble opinion. What if I wanted to return an integer, 2 strings, and a DateTime? Today, I'd just use a struct or out parameters. Easy enough. It'd just be NICE to be able to return everything. Like the ?? operator. Not necessary, but still useful. Again, just my humble opinion. :)
Kyosa Jamie Nordmeyer - Taekwondo Yi (2nd) Dan Portland, Oregon, USA
-
The Powers Collection or a simple hand rolled generic handles tuples, Pair<int, int> I have always said that developers need to focus on mastering what has been provided in 2.0 before even thinking about adding more candy.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.Ennis Ray Lynch, Jr. wrote:
I have always said that developers need to focus on mastering what has been provided in 2.0 before even thinking about adding more candy.
Would it really be hard to "master" tuples as a return paramter? I love that feature as part of LUA and Python especially over out parametes. Spec# sounds interesting which adds support for explicit programming by contract.
Todd Smith
-
I'd love to be able to check if say, myObject was null and if it was, return a result, and if not, return a property of myObject using the ?? operator.
Christian Graus No longer a Microsoft MVP, but still happy to answer your questions.
Wait, that may have come out wrong but that is something I really would love to have.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego. -
Why const? What will it even do besides limit the programmer in the usage of said parameters?
In a language where most things are passed by reference, there's even more value in an interface making an explicit promise to not alter an object that it is given to work with. How does it limit the programmer ? If you want to alter an object, don't mark it const.
Christian Graus No longer a Microsoft MVP, but still happy to answer your questions.
-
I'd love to be able to check if say, myObject was null and if it was, return a result, and if not, return a property of myObject using the ?? operator.
Christian Graus No longer a Microsoft MVP, but still happy to answer your questions.
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
-
Good ideas. Have you suggested them to MS?
I didn't get any requirements for the signature
Twice, yes. Both times the C# team argued about the complexity of introducing named optional params, and I said, I'm not asking for that. just some simple syntactic sugar ( the compiler can just generate the methods that pass the defaults through ). Like banging your head against a wall. Of course, now I am not an MVP, because I hate Vista, so I can't suggest anything anymore.
Christian Graus No longer a Microsoft MVP, but still happy to answer your questions.
-
Christian Graus wrote:
optional parameters
Ditto - one of the few things that I prefer in VB.NET. Creating loads of overloads is a royal PITA.
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)Yes, it's something the compiler could easily do for you.
Christian Graus No longer a Microsoft MVP, but still happy to answer your questions.
-
Ennis Ray Lynch, Jr. wrote:
I have always said that developers need to focus on mastering what has been provided in 2.0 before even thinking about adding more candy.
Would it really be hard to "master" tuples as a return paramter? I love that feature as part of LUA and Python especially over out parametes. Spec# sounds interesting which adds support for explicit programming by contract.
Todd Smith
It is more that .NET 2.0 provide the exact construct as required to perform the action without the need for a language update. I am not saying it is hard to master but I am constantly seeing instances of persons requesting features that are already supported.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego. -
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.
Christian Graus wrote:
optional parameters
Mixing optional parameters and overloads can lead to pretty bad mess.
-
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
-
Christian Graus wrote:
optional parameters
Mixing optional parameters and overloads can lead to pretty bad mess.
Yeah, the C# team explicitly stated they always try to make the language simple rather than powerful. Which is retarded IMO. Sure, you can make mistakes with powerful features, but that's not the point.
Christian Graus No longer a Microsoft MVP, but still happy to answer your questions.
-
Why do you need this feature since currently object, array and many other types can be returned or passed by reference.
TOMZ_KV
Sigh. As I've said above numerous times, it's not NEEDED, it'd just be nice. :) The ?? operator is not needed. But it's a great shortcut. The foreach construct isn't needed. But it's a great shortcut (you could do the same thing with a while loop, checking whether the MoveNext method of the enumerator returns false). Same with the idea of tuples. I'd rather be able to return 3 or 4 values than have to deal with the messiness of out parameters, or having to define multiple structs to handle each return combination that I might need.
Kyosa Jamie Nordmeyer - Taekwondo Yi (2nd) Dan Portland, Oregon, USA
-
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.
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.
-
Why const? What will it even do besides limit the programmer in the usage of said parameters?
harold aptroot wrote:
Why const? What will it even do besides limit the programmer in the usage of said parameters?
Well, that's kind of the point. You want to limit the usage of const parameters to minimize side-effects.
-
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.
C++ does it. I don't see why C# shouldn't, either. I accept it's less trivial than optional params.
Christian Graus No longer a Microsoft MVP, but still happy to answer your questions.
-
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
I'd like to see a default class property. I wrote a thin wrapper for a web service the other day, and instead of being able to access the nested object transparently, I had to add another layer of indirection. eg:
private WebServiceWrapper service = new WebServiceWrapper(); // To access the aggregate web service, we have to do this: service.AggregateService.Method(); // instead of the much more elegant: service.Method();
Sunrise Wallpaper Project | The StartPage Randomizer | The Windows Cheerleader
-
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 function's return type being part of it's signature and not just the arugment list; so int functA(string abc); string functA(string abc); does not cause a compile error when they are in same class.
MrPlankton