W3C home > Mailing lists > Public > public-sysapps@w3.org > December 2013

Re: Method parameter - optional but not nullable

From: Christophe Dumez <ch.dumez@sta.samsung.com>
Date: Wed, 18 Dec 2013 14:53:37 +0000
To: "Huang, Deqing" <deqing.huang@intel.com>, "public-sysapps@w3.org" <public-sysapps@w3.org>, Christophe Dumez <ch.dumez@sta.samsung.com>
Message-ID: <11AF15D5CCFAB74BA4874868E6591AB1029043@exMB1.telecom.sna.samsung.com>
Hi,

Yes, optional and nullable mean different things in Web IDL.

find is specified as follows:

Promise<http://www.w3.org/2012/sysapps/contacts-manager-api/#dfn-promise> find<http://www.w3.org/2012/sysapps/contacts-manager-api/#widl-ContactsManager-find-Promise-ContactFindOptions-options> (optional ContactFindOptions<http://www.w3.org/2012/sysapps/contacts-manager-api/#idl-def-ContactFindOptions> options);

As per Web IDL [1], Dictionaries are not nullable when used as the type of an operation argument (or a dictionary member).

So null will never be passed to the implementation of find().

However, calling "navigator.contacts.find(null);" will not throw. Instead, null will be converted to a dictionary as defined by Web IDL [2] and that dictionary will be passed to the implementation of find().

[1] http://heycam.github.io/webidl/#idl-nullable-type
[2] http://heycam.github.io/webidl/#es-dictionary (See Step 5.2. if Type(V) is Null)

Kr,

On 12/18/2013 05:03 AM, Huang, Deqing wrote:

Hi,

In Contacts Manager API spec, parameter "option" of find() is optional but not nullable:
http://www.w3.org/2012/sysapps/contacts-manager-api/#widl-ContactsManager-find-Promise-ContactFindOptions-options

What does that mean? Is there any difference between optional and nullable?

Thanks in advance.

Regards,
Deqing






--
Christophe Dumez - Samsung Telecommunications America
Received on Wednesday, 18 December 2013 14:54:06 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:36:18 UTC