questions on nullability

Burak Emir Burak.Emir at epfl.ch
Thu Jun 15 01:53:54 PDT 2006


Hi there,

The "Nullability" proposal reads 
http://developer.mozilla.org/es4/proposals/nullability.html

zzz
Classes can be defined to be non-nullable by default via a special 
declaration syntax:

class C! { ... }

This annotation does not imply anything about subclasses of C; they are 
still nullable by default unless declared non-nullable.
zzz

This triggers some questions.
a) can I write

var c: C = new C // (1), or
var c: C! = new C // (2)

or are both equivalent (3)? IMHO explicit is better than implicit.

b) assuming only (3) is allowed (it doesn't really matter here), 
consider the subclass mess:

class D extends C! {} // subclass can still be nullable
var c: C
var d: D = null
...
c = d

As I understand the proposal, this should not be allowed, because C does 
not include null, but D does?

c) (unrelated to above) how can one turn a value of type A into a value 
of type A! in order to guide the typechecker? a cast? a preceding 
if(a!=null)?

cheers,
Burak

-- 
Burak Emir

http://lamp.epfl.ch/~emir




More information about the Es4-discuss mailing list