Re: [WebIDL] A new way to define UnionTypes

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.

-Boris

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