W3C home > Mailing lists > Public > public-script-coord@w3.org > April to June 2012

Re: Nullable union types containing other nullable types

From: Cameron McCormack <cam@mcc.id.au>
Date: Sat, 14 Apr 2012 13:43:01 +1000
Message-ID: <4F88F245.6060903@mcc.id.au>
To: Boris Zbarsky <bzbarsky@MIT.EDU>
CC: "public-script-coord@w3.org" <public-script-coord@w3.org>
Boris Zbarsky:
> Consider this idl:
>    void foo((A? or B)? arg);
> Is this allowed?  At first glance, it is.

No, in #idl-nullable-type it says:

   The inner type MUST NOT be any or another nullable type or a union
   type that itself has a nullable type as a member type, as they
   already allow the null value.

> Should this be allowed?  I guess there's no reason it shouldn't be; it
> just seems weird to write IDL like that...  Passing null or undefined
> would just convert to IDL null because the union is nullable, o the '?'
> after A is just pointless, right?

Yeah, I don't think there's any real need to allow this.  (It let me 
simplify some language dealing with union types this way, too.)

The only reason we *might* like to allow this is if you had a typedef 
for some type that was nullable:

   typedef sequence<long>? Numbers;
   typedef sequence<DOMString>? Letters;

which meant that you couldn't write for example

   void f((Numbers or Letters) x);

and you'd need to expand out the typedef.  Probably not something that 
would come up often, though.
Received on Saturday, 14 April 2012 03:43:42 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:06 UTC