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

Allowing IDL attributes to have different types for the getter and setter

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Wed, 17 Apr 2013 21:38:48 -0400
Message-ID: <516F4EA8.6050103@mit.edu>
To: "public-script-coord@w3.org" <public-script-coord@w3.org>
This has come up a few times now.

Right now in WebIDL an attribute has a single type associated with it: 
the setter coerces the given value to that type if it can, and the 
getter returns that type.

It's not a priori obvious that this is a great fit for all APIs, 
especially because of the restrictions in WebIDL on attribute types not 
being sequences or dictionaries ... which are there just because 
_returning_ those from an attribute would not be good.

So a question in terms of API design: from the point of view of JS API 
consumers, does it make sense to have an attribute whose setter, say, 
takes an array of File or Blob objects, or a single File or Blob object, 
but whose getter always returns some object (always the same one) that 
represents the current set of File/Blob objects we've got?  That sort of 
thing is not possible to declare in WebIDL right now.  Should it be?

There's relevant discussion in 
https://bugzilla.mozilla.org/show_bug.cgi?id=757664 and 
https://www.w3.org/Bugs/Public/show_bug.cgi?id=20407 for those who are 
interested.

-Boris
Received on Thursday, 18 April 2013 01:39:19 UTC

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