Separating a Hash type from Object

zwetan zwetan at gmail.com
Mon May 7 06:22:57 PDT 2007


On 5/7/07, Lars T Hansen <lth at acm.org> wrote:
[snip..]
>
> Following is the proposed API for the dictionary class, note this
> proposal has been *rejected* for ES4.  It would be rejected even
> without the provision for weak refs.  I'm including it only to make
> the point that, like a lot of other data structures, it can be
> implemented in portable ES4 and does not need to be part of the
> language.  (That happens not to be the case for ByteArray, whose
> entire reason for existence is storage efficiency coupled with
> performance.)
>
> class Dictionary.<K,V> {
>     function Dictionary(weak: boolean = false)
>     public function from(x : Object!)
>     public function size() : uint
>     public function get(key: K) : V?
>     public function put(key:K, value:V) : void
>     public function has(key:K) : boolean
>     public function remove(key:K) : boolean
>     iterator function get(deep: boolean = false) : iterator::IteratorType.<K>
>     iterator function getKeys(deep: boolean = false) :
> iterator::IteratorType.<K>
>     iterator function getValues(deep: boolean = false) :
> iterator::IteratorType.<V>
>     iterator function getItems(deep: boolean = false) :
> iterator::IteratorType.<[K,V]>
> }
>

so if this API can be implemented in ES4, where is the problem ?

it's hard to follow here why people even discussing all that,
as I see it if such API has been *rejected*, what are the chances
for a new syntax as obj.#toString to be *accepted* ?

maybe adding to catchall (
http://developer.mozilla.org/es4/proposals/catchalls.html )
would have better chances to be *accepted* ?

for ex:
function get *(ident), the catchall getter. (return the value)
-> function get2 *(val) (return the ident)

function intrinsic::get(ident), the non-overridable universal property getter.
-> function intrinsic::get2(val)

afaik, the Dictionary class in AS3 is very usefull to avoid O(n)
search of ident,
maybe I don't fully understand the whole problem here, but for hashes speed
sake some *magic* O(1) access to the ident would be more than welcome.

cheers,
zwetan



More information about the Es4-discuss mailing list