W3C home > Mailing lists > Public > whatwg@whatwg.org > September 2009

[whatwg] Web Storage: structured clones lead to ambiguity in detecting if a key is set w/ getItem()

From: Erik Arvidsson <erik.arvidsson@gmail.com>
Date: Wed, 23 Sep 2009 14:37:41 -0700
Message-ID: <6eeb8bd10909231437m323e359fyf745dc96d7d18e8c@mail.gmail.com>
On Wed, Sep 23, 2009 at 14:28, Jo?o Eiras <joaoe at opera.com> wrote:
> On Wed, 23 Sep 2009 23:03:38 +0200, Erik Arvidsson
> <erik.arvidsson at gmail.com> wrote:
>
>> What are the arguments against adding a containsKey method? This would
>> map consistently to the in operator and hasOwnProperty in ES5.
>> object.containsKey(name) would be mapped to [[GetOwnProperty]](object,
>> name) !== undefined in ES5 meta language. That seems most consistent
>> to existing APIs.
>>
>
> A containsKey or hasItem, preferably, would still not address the ambiguity
> issue.

ES and most other languages that do not throw when you try to get a
non existing item out of a collection will have this problem. If they
return a value, getItem will never be able to tell if that value was
due to an absent item or not. The only way to make getItem handle this
is to either throw or return two values. Both are not very consistent
with other web apis.

>
>
>



-- 
erik
Received on Wednesday, 23 September 2009 14:37:41 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:08:52 UTC