C# 4.0
-
It's been awhile since I did any c++, but I believe you would get a compile warning with Borlands old c++ compiler and then it would take it's best guess. Casting the function call would make the compiler happy. They could do the same with next version c#.
MrPlankton
MrPlankton wrote:
It's been awhile since I did any c++, but I believe you would get a compile warning with Borlands old c++ compiler and then it would take it's best guess
I'd rather not see it. I treat compiler warnings as errors, but from time to time I have to work with people who do stuff like try..catch with the general exception and don't even log the exception message. :( The compiler cries of course but no one pays attention. *sigh* That proposed feature is very interesting, but I'm afraid of it. ;)
-
well then how about a void functA("a"); one would assume that this default case would be anticipated by programmer, but failing that; the syntax could be; (cast)functA("a"); and that would work to even though there is no left param; but compiler would flag functA("a"); with a warning. Would that work for you? What would you like to see?
MrPlankton
MrPlankton wrote:
well then how about a void functA("a");
What if there's not such method?
-
Me too. I think they already degraded the language in C# 3 by adding extension methods and partial methods just to sell LINQ.
Sunny Ahuwanya "The beauty of the desert is that it hides a well somewhere" -- Antoine de Saint Exupéry
Sunny Ahuwanya wrote:
I think they already degraded the language in C# 3 by adding extension methods
I think of them as of an improvement and use them. :)
-
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
Static verification would be awesome. Contracts[^] would be nice too if they could get some of those features in without making too much of a mess. For instance, Spec# will throw a compile-time error (and squiggly underline in Visual Studio) with this code:
public float Divide(float x, float y)
{
return x / y;
}But this would be valid:
public float Divide(float x, float y)
requires y != 0
{
return x / y;
}As would this:
public float Divide(float x, float y)
{
if(y == 0)
throw new ArgumentException("y");
return x / y;
} -
Why const? What will it even do besides limit the programmer in the usage of said parameters?
-
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
do anybody suggest me any gud article on 4.0 And what is the raod map of 4.0
-
1. one of main differences between high-level languages and assembly language is that they introduces many ways to limit the programmer 2.
const
keyword is not only a limitation it is also a reminder for you and for others that there is a reason why something should not be changed. Andconst
is certainly a better solution than running around the office saying 'promise me that you will not try to change data returned bySomeLongAndCrypticFunctionName
'Mladen Jankovic wrote:
And const is certainly a better solution than running around the office saying 'promise me that you will not try to change data returned by SomeLongAndCrypticFunctionName'
Yes, but running is good for you! :laugh:
To hell with circumstances; I create opportunities.
-
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.
I am astounded they don't support const parameters yet. Naturally, if they support const parameters, they will almost certainly have to support const methods. I think const parameters are one of the best things about C++ that got dropped out in C#.
Cheers, Vıkram.
"You idiot British surprise me that your generators which grew up after Mid 50s had no brain at all." - Adnan Siddiqi.
-
Christian Graus wrote:
const keyword on parameters to methods
But how would the compiler verify the "constness" of methods that you call on a const object? The methods themselves would have to be declared const, just like in C++. Everything, including the BCL, will need to change for that. There's also the versioning problem. In C++, if a library changes, you are forced to recompile with the modified header files. There's no such need in .NET, so if a method declared const in v1 of the library became non const in v2, the "constness" guarantee will get broken (unless there is a runtime check).
Regards Senthil [MVP - Visual C#] _____________________________ My Home Page |My Blog | My Articles | My Flickr | WinMacro
S. Senthil Kumar wrote:
The methods themselves would have to be declared const, just like in C++.
Yeah, I wrote that myself, without reading your post. :doh:
S. Senthil Kumar wrote:
if a method declared const in v1 of the library became non const in v2, the "constness" guarantee will get broken (unless there is a runtime check).
I'm not sure I understand, could you please explain?
Cheers, Vıkram.
"You idiot British surprise me that your generators which grew up after Mid 50s had no brain at all." - Adnan Siddiqi.
-
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 have local static varibles.
-
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 the ability to partially set array values. For example, for an int array of length 10 with default values of 0..9 respectively, the following would be valid:
myArray[3..5] = (-3, -4, -5);
The contents would then be: 0, 1, 2, -3, -4, -5, 6, 7, 8, 9 Another idea is a composite Label (say Strings and Images). The display of CompositeLabel.Text would display a String followed by an Image then we could have things (using my mythical System.Text.SmileyFace namespace) like . . .
myCompositeLabel.Text = "Hello, World " + System.Text.SmileyFace.BigGrin.ToImage();
The display would then be: Hello, World :-D Anthony
-
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 bet 99% of you disagree with this one! I would like to see multiple inheritance and full operator overloading available in C#.
-
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 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.
The good answer to 'constness' is spec#. The 'constness', the 'nonnullness', the 'checkedexceptionness' , the 'immutabilityness' etc ... are all describable with contracts. I think Spec# will be a real revolution in the .NET world. In fact the .NET infrastructure should evolve to include contract metadata so that every .NET language will manage contracts in a similar way. Try it here http://research.microsoft.com/SpecSharp/[^] ... and cry because I am sure that c#4 won't include spec# :-(
-
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
an IMaths interface so writing maths libraries with generics is simpler
-
Because if you're providing an interface, you provide a contract with the people who use that interface. If I write a library, I can use const to tell a user when they can trust my code not to change their stuff.
Christian Graus No longer a Microsoft MVP, but still happy to answer your questions.
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
-
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
That's the best and most practical suggestion for c# I've seen. has anybody raised it to MS?
Smokie, this is not 'Nam. This is bowling. There are rules. www.geticeberg.com
-
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 do sort of like the idea but isn't a function by definition a thing that only returns a single value? Maybe we need anonymous returns instead so that you define a struct on the fly, thus returning a single entity that contains the multiple values. public {Max int, Min int} MinMax(int[] numbers) { int min, max; // Code to calculate min/max return {min, max}; } called with var v= MinMax(myArray); system.out.println(v.Min); system.out.println(v.Max); otherwise you'd end up having to create something wierd like this to get the values back int min, max = MinMax(myArray); Russell
-
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.Hallelujah!