Re: [WebIDL] add text to discourage `[Optional] Interface / [NoInterfaceObject] interface Interface` and encourage `dictionary Dictionary` instead

On 31/08/11 3:50 AM, Allen Wirfs-Brock wrote:
> That sounds like it would discourage patterns like this:
>
> [NoInterfaceObject]
> interface SomeOpaqueType {};
>
> interface SomeResourceManager {
> SomeOpaqueType getSomeResource(...);
> void operateUsingResource(in SomeOpaqueType);
> }
>
>
> I don't see why you would want to discourage this as it is a well
> understood design pattern. For example see,
> http://web.cecs.pdx.edu/~antoy/flp/patterns/#Opaque%20Type
> <http://web.cecs.pdx.edu/~antoy/flp/patterns/#Opaque Type>

My question here would be why make SomeOpaqueType [NoInterfaceObject]? 
The original interface would need to be [Callback] also, so that JS 
objects could be considered "user objects" of that interface, so the 
above would be safe from timeless' wording.

I think anyway that the guidance in the spec should be worded more along 
the lines of:

   When writing an API that uses an ECMAScript object as a "property
   bag" like function argument, specification authors are recommended
   to use IDL dictionaries to handle these rather than a
   [Callback,NoInterfaceObject] interface with attributes defined on it.

Received on Thursday, 1 September 2011 05:16:21 UTC