On Thu, Sep 9, 2010 at 07:08, Tom Van Cutsem <tomvc...@gmail.com> wrote:
> Both of these seem to be compelling advantages of soft fields over names.
> However, I wonder if it would be possible to get the best of both worlds.
> IIUC, the Names proposal converts:
> private x;
> this.x = "foo";
> this.x
>
> into:
> let x = new Name;
> this[x] = "foo";
> this[x]
> Would it be possible to instead rewrite it to:
> let x = new ExplicitSoftField();
> x.set(this, "foo");
> x.get(this)
> (using the same rules for determining the scope of 'x' as detailed in the
> Names proposal)
> You would get the 'private' scoping of Names, and the concise syntax,
> without the limitations that MarkM raised. Am I missing something?

+1

x could also be a WeakMap in the sample above. This reminds me;

I still don't understand why we would want both ExplicitSoftField and
WeakMap. If we make the API for WeakMap not so bare bone it can cover
both use cases.

The thing I like with the Names proposal compared to using WeakMaps is
that using WeakMaps feels very backwards.

-- 
erik
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to