On 1 Jul., 12:45, B Smith-Mannschott <[email protected]> wrote:
> On Wed, Jul 1, 2009 at 11:20, Ben Schulz<[email protected]> wrote:
> >> The problem with Java's null is the instance of bottom in the static
> >> type system, but outside the dynamic type system. Classic puzzler:
>
> >> public boolean puzzle(String par) {
> >>     return (par instanceof String);
>
> >> }
>
> >> How to get a false? Pass a null. The type systems don't match.
>
> > Yes, this really should return true for null, however since (right
> > now, in Java) null is allowed everywhere, I don't mind so much.
>
> No, it shouldn't return true for null. You're confusing *instanceof*
> with some hypothetical iscompatiblewithtype. Null is not an *instance*
> of anything. There's *nothing* there. It's null.

Section 4.1 of the JLS disagrees with you, the null type is there, you
just can't name it as part of a Java sentence. And it's a pity that
it's so, but I understand the reasoning behind it (
http://blogs.sun.com/abuckley/entry/naming_the_null_type ).

> Sorry, but the sloppy way null is used in typical Java code is one of
> my pet peeves.

Me too, which is why I don't mind that "null instanceof Whatever"
denotes false. However, if one could express "null instanceof @NonNull
Whatever" and the @NonNull was actually respected by the runtime, then
I would mind.

> // Ben /* oh no, name clash ;-) */

Yeah, happens to me all the time -- my last name's no better in that
respect either. :D

With kind regards
Ben
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to