W3C home > Mailing lists > Public > public-script-coord@w3.org > October to December 2012

Re: [WebIDL] Would it make sense to add annotations for "creates a new object each time" and "always returns the same object"?

From: Ojan Vafai <ojan@chromium.org>
Date: Mon, 22 Oct 2012 18:34:06 -0700
Message-ID: <CANMdWTusrjNzsy+W_nhtyqn1U+qWpknCK2N_CGnW6Bg9-yNQng@mail.gmail.com>
To: Glenn Adams <glenn@skynav.com>
Cc: Boris Zbarsky <bzbarsky@mit.edu>, "public-script-coord@w3.org" <public-script-coord@w3.org>
On Thu, Oct 18, 2012 at 5:55 PM, Glenn Adams <glenn@skynav.com> wrote:

>
>
> On Thu, Oct 18, 2012 at 9:11 PM, Boris Zbarsky <bzbarsky@mit.edu> wrote:
>
>> Consider a method declaration like so:
>>
>>   MyInterface getFoo();
>>
>> It's impossible to tell from that IDL whether you get back the same
>> object every time or whether the same object is returned each time, or
>> whether it's sometimes the same and sometimes a new one.  Generally you
>> have to rely on the prose to indicate that, and often the writers of the
>> prose forget to do so.
>>
>> In Gecko, we have found it useful to annotate methods and attributes with
>> this sort of information (we use [Creator] for methods that always return a
>> new object and we're about to add an annotation for attributes that always
>> return the same object, but we haven't decided on a name for it yet).
>>
>> Would it make sense to add such annotations to WebIDL so that this sort
>> of thing doesn't have to be described in prose?
>
>
> +1
>

I don't have strong opinions on whether it makes sense to add such an
annotation to WebIDL. The direction we've taken with things that return
lists for new APIs is to have properties always return the same object.
Hence the following requirement for Sequences: "Sequences must not be used
as the type of an attribute, constant or exception field." There's nothing
saying that methods should always return a new object, but it seems like
the right way to be consistent with the approach to sequences.

Obviously, there's nothing we can do about legacy APIs, so it might still
make sense to add the annotation even if we decide that methods should
always return a new object.
Received on Tuesday, 23 October 2012 01:34:55 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 8 May 2013 19:30:07 UTC