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

WebIDL extension proposal for [Enumerable] interface attribute

From: Anselm R Garbe <anselm@aplixcorp.com>
Date: Wed, 1 Jul 2009 11:36:33 +0100
Message-ID: <89d1e7b80907010336i68437abayd682d74c702c0e5b@mail.gmail.com>
To: public-webapps@w3.org
Hi there,

in a mail[1] earlier today, Marcin introduced some ideas we discussed
recently on the BONDI interfaces list. I noticed in the archives that
you had a related discussion about the geolocation PositionOptions and
also some conclusions like using the [Callback] attribute. As it has
been mentioned already, we identified various use cases of map-like
objects in the BONDI APIs, which are similiar to PositionOptions, but
not equal in all aspects.

We concluded that usually APIs will use two kinds of option objects,
value type interfaces and map-like interfaces. As a rule of thumb,
value type objects are often used as input arguments to APIs, whereas
map-like objects are mostly used as output arguments. A value type
interface can be easily specified already using WebIDL, however a
map-like interface has some constraints which can't be formally
specified atm.

- all attributes must be enumerable
- all attributes must be optional -- we'd like to formally specify
common attributes that are *usually* supported by API implementations
but must not
- the types of the specified attributes might differ from the actually
exposed values by a specific implementation due to the optionality of
the attributes
- the interface is extensible outside the spec scope -- an object that
implements such an interface can expose other/additional attributes
than the specified ones

For example, we are using a Map-like object that exposes file metadata
which differs among different files (eg an MP3 file has totally
different metadata than an executable), but the metadata might also
contain commonly used attributes like the file size or creation date.
Our current approach to this problem is to declare

typedef Object Map;

and using the Map type for these occasions with an informal
documentation of the actual Map attributes and their values. However,
we'd like to achieve a more formal way to do so.

That's why we propose the introduction of an extended interface
attribute called [Enumerable] into WebIDL and the introduction of the
extended attribute [Optional] for interface attributes. Given the
example of file metadata, such a map could be specified as follows:

[Enumerable] interface FileMetadata {
  [Optional] attribute long size;
  [Optional] attribute Date creation;
  [Optional] attribute Date modification;
};

A generic Map-like interface that has no defined optional attributes
could look like:

[Enumerable] interface Map {};

What is your point of view?

[1] http://lists.w3.org/Archives/Public/public-webapps/2009JulSep/0019.html

Kind regards,
Anselm
Received on Wednesday, 1 July 2009 14:51:06 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:32 GMT