Linked by Owen Anderson on Mon 19th Apr 2004 05:43 UTC
General Development For years the development scene has been dominated by the C family of languages, primarily C itself and its immediate successor C++. Recent years have given rise to other C-descendents, however, such as Sun's Java and Microsoft's C#.
Permalink for comment
To read all comments associated with this story, please click here.
RE: Null Pointers
by Marcus Sundman on Tue 20th Apr 2004 20:35 UTC

> What is wrong with having the two be equivalent?

Uh.. because they are different? What is wrong with you? 2!=3, "a"!="b", "a"!=null and ""!=null. An empty string is NOT nothing, it is something, namely a string, just as the string "a" is a string. This is not something that can be negotiated, such as whether "a"=="a" or "a"!="a" (i.e. they might be different objects but still equivalent). This is as clear as "a"!=2 and 42!=0.

> As I said, since you are already loading the register

Will you stop talking about irrelevant implementation details when I'm trying to discuss the language! Or is the point you're trying to get across that you know that it's wrong that ""==null, but that it is faster and therefore justified? If this is what you're trying to say then fair enough, we disagree, I don't think it's justified, but let's leave it at that. However, if this is not what you're trying to say then you have to be clearer, because neither I nor anyone whose opinion I've asked about your writings have a clue what you're trying to say.

> Say that a is not equal to b from your example above.

As is the case, yes.

> Now someone passes in a or b set to null.

Huh? Pass in where? It doesn't matter what a and b is before that block of code since I very explicitly set a to "" and b to null on the very first line. Helloo-oo?

> This case must be handled using separate code or risk
> a dangling reference to unmapped memory.

What are you smoking, man?!? Which variable do you think would be a dangling reference to unmapped memory? 'a' is a pointer to a string object (be it a struct or whatever) and 'b' is a pointer to nothing. Besides, how on earth do you even think you could get a dangling reference at all in a fully GC'd language (unless you use arithmetics on pointers or mark that code as to be excluded from GC)?