- From: Dominique Hazael-Massieux <dom@w3.org>
- Date: Thu, 28 Jan 2010 19:43:12 +0100
- To: public-script-coord@w3.org
WebIDL currently states that an interface type is:
A scoped name that resolves to an interface is used to refer to
a type that corresponds to the set of all possible references to
objects that implement that interface, *plus the special value*
null, which indicates no object reference.
http://dev.w3.org/2006/webapi/WebIDL/#idl-interface [emphasis mine]
As a consequence,
It is not possible to have a type Node?, since interface types
already allow the null value.
http://dev.w3.org/2006/webapi/WebIDL/#idl-nullable-type
I think it is rather counter-intuitive that
boolean foo(MyGreatInterface bar);
already allows
foo(null);
In practice, I discovered this aspect of WebIDL only because the WebIDL
checker is choking on similar constructs e.g. on the Contacts API:
PendingOp find (in ContactProperties filter, in
ContactFindSuccessCB successCB, in optional ContactErrorCB?
errorCB, in optional ContactOptions options);
http://www.w3.org/2009/07/webidl-check?doc=http%3A%2F%2Fwww.w3.org%2FTR%
2F2010%2FWD-contacts-api-20100121%2F&input=&output=html
Arguably, this is something that can be fixed in the Contacts API, but
before submitting the bug report, I was wondering what was the rationale
for forbidding the use of "?" on interface types; in particular:
• why interface types include the null value?
• why is it forbidden to make nullable a type that already includes the
null value?
(I'm sure my questions are naive, but I'm not sure where to look for
answers to them)
Dom
Received on Thursday, 28 January 2010 18:43:22 UTC