Re: C# 3.0 Proposals

Tech-Archive recommends: Speed Up your PC by fixing your registry



Otis Mukinfus <phony@xxxxxxxxxxxxxxxx> wrote in
news:lhi8729eii5rdujqaa5gbdpt9qkhsqofbd@xxxxxxx:

Being ambiguous is precisely what is wrong with it....

Suppose I use the implicit declaration like this:

var d = 10; // double but the compiler will probably think it's int32
var i = 10; // int32 but the compiler will probably think it's int32
var j = 10; // int64 but the compiler will probably think it's int32

The compilers will not think it's int32, it will know it is int32. Since
10 _is_ int32.

Use suffixes to indicate type in constants:
var d = 10d; // double and the compiler will know it's double
var i = 10; // int32 and the compiler will know it's int32
var j = 10l; // int64 and the compiler will know it's int64

The suffixes you can use are:
l or L for long
u or U for unsigned
d or D for double
f or F for float
m or M for decimal

There is not suffix for short or byte

On the other hand, I would be sceptical about code the uses 'var' like
this.

--
Rune Huseby
.



Relevant Pages

  • Re: C# 3.0 Proposals
    ... Suppose I use the implicit declaration like this: ... The compilers will not think it's int32, it will know it is int32. ... Use suffixes to indicate type in constants: ... but as I said in my first post without the suffixes the compiler would interpret ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: C# 3.0 Proposals
    ... The compilers will not think it's int32, it will know it is int32. ... It's not the compilers fault that you didn't write what you intended. ... A programming language never creates bad code, bad programmers do. ...
    (microsoft.public.dotnet.languages.csharp)