Re: C# Nullable types



Again, you are getting phillisophical, rather than being pragmatic. I have
found that you will twist any argument in any way to prove your point.

Your agument could easily be analogous to the universe's size being
infinate. But does the universe have a particular value for its size? You
argue "Yes" - Its size is infinate, I argue "No" - there is no particular
size, which is expressed by saying infinate.

null is just a word - it's meaning is widely known to be "no value".

You can twist your words in any way that you like, but all you are doing is
making this way more complicated than it need be.

I know you know (despite your public stance here) that:

string x = null;

means that x should be initialized to no particular value and we tell the
compiler that by using the language specific word called "null". In VB,
we'd use the language specific keyword "Nothing".

But, I also know you know that:

string x;

is an unitialized variable. The compiler needs to make this distrinction
(between intentionally not specifying a value and perhaps not setting a
value by mistake), so we are given a keyword to state our intentions as the
developer. In other words, null is just a word we use to tell the compiler
what our intentions are. In C#, uninitialized variables are mostly not
allowed (because of the DAR), but we can pass compilation but stating our
intentions:

string x = null;

I am saying that I don't want x to have any value and I am "ok" with that.
The compiler then says, "ok, as long as you use x correctly and you know
what you are doing".




"Jon Skeet [C# MVP]" <skeet@xxxxxxxxx> wrote in message
news:MPG.207f4da7e1b9848098da89@xxxxxxxxxxxxxxxxxxxxxxx
Scott M. <s-mar@xxxxxxxxxxxxx> wrote:
John, I'm not going to split unecessary hairs with you, yet again.
Contrary
to your statement, I believe that (in programming terms) saying something
has no value at all and something not pointing to an instace are, in
fact,
saying the same thing.

Do you not see how "no value at all" and "a special value" are
contradictions? According to the C# spec at least, null *is* a value.
To say it's not a value contradicts that.

If I do:

string x = null;

then the variable x has a value - the null value, which refers to no
instance.

If I do:

string x;

then the variable x has no assigned value yet, as far as C# is
concerned.

The point of my last comment is that the statement ""Null" means what the
code designer says it means." and the statment "Given that "the meaning
of
'null'" is arbitrary" are both incorrect.

On that point I agree with Peter - that it's reasonable to say (in a
particular situation) what semantic meaning a "null" value has, how it
should be interpreted for that particular variable/return value etc. On
this point, it seems to me that you're the one splitting hairs.

--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too


.



Relevant Pages

  • Re: C# Nullable types
    ... specified terminology rather than whatever terminology they happen to ... string x = null; ... compiler that by using the language specific word called "null". ... so we are given a keyword to state our intentions as ...
    (microsoft.public.dotnet.framework)
  • Re: C# Nullable types
    ... specified terminology rather than whatever terminology they happen to ... string x = null; ... compiler that by using the language specific word called "null". ... so we are given a keyword to state our intentions as the ...
    (microsoft.public.dotnet.framework)
  • Re: C# Nullable types
    ... specified terminology rather than whatever terminology they happen to ... string x = null; ... compiler that by using the language specific word called "null". ... so we are given a keyword to state our intentions as ...
    (microsoft.public.dotnet.framework)
  • Re: No coercion in for-each loop?
    ... It is true that the compiler does not mind when you code ... List<String> list=ar even though ar may contain non String objects. ... I don't see that you are saying this in the above code. ... doesn't actually barf on the cast, ...
    (comp.lang.java.programmer)
  • Re: Letter to US Sen. Byron Dorgan re unpaid overtime
    ... Big-O notation isn't mathematics per se, it's computer science notation ... "length of the string". ... outrun something compiled and optimized by a good C compiler. ... > either general computing culture or culture outside computing. ...
    (comp.programming)