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

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