[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] New immediate values (was: DBI)
From: |
Thomas Chust |
Subject: |
Re: [Chicken-users] New immediate values (was: DBI) |
Date: |
Sat, 01 Mar 2008 02:56:42 +0100 |
On 29. Februar 2008 17:28:37 -0500 John Cowan <address@hidden> wrote:
Thomas Chust scripsit:
this is really a question of taste, isn't it? You could just as well
argue that a NULL value should be of a type that is a subtype of every
other existing type but contains no other concrete instances, which
would imply that all the type predicates should return #t when applied
to the NULL value. This makes a lot of sense when the NULL value is
used to indicate the absence of an object reference and is the way it
is handled in several object oriented languages.
As far as I know, no OO language does that. They interpret (or IMHO
misinterpret) a *static* declaration that a variable is of type Foo
as meaning that it can contain a Foo or null, but nowhere is null
*dynamically* a member of type Foo: tests analogous to number?, string?,
etc. always return false on null.
Hello,
for example in Java there are some places where the dynamic type of null is
effectively a subtype of another class:
// this returns (String)null and doesn't throw a ClassCastException
"foo".getClass().cast(null)
There are also places where the language behaves differently, though:
// this returns false
null instanceof String
So the static typing behaviour may differ from the dynamic one and it may
be inconsistent. But a distinction between static and dynamic typing
behaviour wouldn't apply to Scheme.
Of course I don't want to have the same typing mess as in Java in CHICKEN
and I do think the whole practice of having nullable reference types (by
default) is questionable. I just don't think it is completely canonical
that the type of NULL should be disjoint from every other type, especially
if you think of types as being sets (or classes) of objects.
[...]
OT: One of the Java puzzlers is this:
Foo foo = null;
foo.bar();
Under what circumstances does that *not* cause a NullPointerException?
If Foo.bar is a static method this will work just fine ;-)
cu,
Thomas
--
Murphy's Law is recursive. Washing your car to make it rain doesn't work.
- Re: [Chicken-users] New immediate values (was: DBI),
Thomas Chust <=