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

Re: [WebIDL] A new way to define UnionTypes

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Wed, 29 Aug 2012 11:11:21 -0400
Message-ID: <503E3119.3020300@mit.edu>
To: public-webapps@w3.org
On 8/29/12 7:59 AM, Andrei Bucur wrote:
> I was wondering if it would make sense to use supplemental interfaces as a
> way to generate union types, like in this example:
> X implements S
> Y implements S
> Z implements S
> interface someInterface
> {
> 	NewSyntaxGeneratingUnionTypeFrom(S) someMethod();
> }

Why can't you just do:

  interface someInterface
     S someMethod();


> Having this syntax makes it easy to define functions that will definitely
> return objects adhering to a certain interface but are not necessary
> containing S in the prototype chain.

Yes, that's the idea of "implements"...

> A real life use case for this is the Region interface [1]. Right now, the
> only interface implementing Region is Element. The plan is to also allow
> pseudo elements [2] implement the Region interface. Because Element and
> CSSPseudoElement are totally different types it is impossible to define a
> method that returns a "Region" (e.g. NamedFlow.getRegions() [3]).

Why is it impossible, exactly?  Just define it as returning a Region in 
the IDL.

Received on Wednesday, 29 August 2012 15:11:54 UTC

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