Proposal: Abstract References

Isiah Meadows impinball at gmail.com
Thu Oct 23 07:01:31 PDT 2014


Oh. I see now. The function calling part I understand already.

For the private state ideas, I can see the GC speed nightmare, but for just
function binding, it is extraordinarily similar to LiveScript's `|>`
operator (which has always been useful) in usage, which I'm +1,000 for
that.
On Oct 22, 2014 7:06 PM, "Tab Atkins Jr." <jackalmage at gmail.com> wrote:

> On Wed, Oct 22, 2014 at 1:12 PM, Isiah Meadows <impinball at gmail.com>
> wrote:
> > I know that this could clearly work for implementing private arrays,
> etc. as
> > well, but what about private integer or booleans?
> >
> > ```js
> > let _x = 0;
> > let _y = false;
> >
> > class Foo {
> >   constructor(x, y) {
> >     this::_x = x;
> >     this::_y = y;
> >   }
> >
> >   // ...
> > }
> >
>
> You misunderstand the proposal a bit.  In `x::y`, the y is an object
> that is asked to respond in a special way.  When `y` is a WeakMap, it
> responds to `x::y = z;` by calling `y.set(x, z)` on itself.
>
> You can store whatever you want in there; the `z` value can be
> anything, including numbers or booleans.  But the `y` object needs to
> be something that knows how to respond to the bind operator.
>
> (Similarly, if `y` is a function, by default it responds to `x::y(z)`
> by calling itself with its `this` set to `x`.  This makes it act
> similarly to `x.y(z)`, but without having to actually define `y` as a
> property on `x`.)
>
> ~TJ
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20141023/b4342b97/attachment.html>


More information about the es-discuss mailing list