W3C home > Mailing lists > Public > public-webapps@w3.org > July to September 2012

Re: [WEBIDL] nullable dictionary members

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Thu, 16 Aug 2012 02:25:48 -0400
Message-ID: <502C926C.5020506@mit.edu>
To: public-webapps@w3.org
On 8/15/12 10:05 PM, Jungkee Song wrote:
> Having said that dictionary members are inherently optional by definition,
> is it meaningful (and valid) to mark optional fields as nullable?

Seems like it should be to me, yes.

> dicationary Foo {
>      DOMString iWantToBeRequired = "Default";
>      DOMString? iWantToBeNullable;
>      DOMString iAmAlreadyOptional;
> };
> Do the two dictionary members "iWantToBeNullable" and "iAmAlreadyOptional"
> semantically make any difference?

Yes.  The latter can either be unset or set to a string.  The former can 
be unset, set to a string, or set to null.  Those are different things.

> I was thinking spec writers sometimes encounter situations where they would
> like to explicitly describe certain dictionary members are required while
> others are not.

Dictionaries can't have a required member via IDL, unless the member has 
a default value....

Of course the prose can always call for throwing if a member is not set.

Received on Thursday, 16 August 2012 06:31:41 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 18:13:38 UTC