B Smith-Mannschott wrote: > On Wed, Jul 1, 2009 at 11:20, Ben Schulz<ya...@gmx.net> 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. > > Sorry, but the sloppy way null is used in typical Java code is one of > my pet peeves. > > // Ben /* oh no, name clash ;-) */ > I agree: the dynamic type system is right IMO. Null is not an instance of anything since it doesn't obey any specifications. For example I expect to be able to call toString() on any object type in Java, but null won't be too friendly if I do that.
While the compiler treats the value like an instance of the bottom type, semantically it is not. Peter --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "The Java Posse" group. To post to this group, send email to javaposse@googlegroups.com To unsubscribe from this group, send email to javaposse+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/javaposse?hl=en -~----------~----~----~----~------~----~------~--~---