Proxy

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Proxy

Uther Pendragon
Perhaps it's a bit late... but I'd like to discuss the proxy object.  Notably:  why no way to define a hook for when a property is called as a function.

I think I understand *why* there isn't one..  I presume because how a property is used (I.e. as a property or called as a function) is a level deeper than the recalling of said property.  If at all possible, I think it would be incredibly useful.  This may be outside the intended purpose of the proxy object, but a proxy for the purposes of a middleware (I hate that word too) that is more dynamic  would be perfect for adaptors etc...  Perhaps it's not feasible, because the proxy hook is best applied at the point when the property's definition, which brings me to my next suggestion....

What about the ability to alter / define the configuration of a scope variable, like those on objects with defineProperty... but with simple scope variables...  I presume most implementations define scope variables much like object properties internally.

On Dec 14, 2016 2:56 PM, <[hidden email]> wrote:
Send es-discuss mailing list submissions to
        [hidden email]

To subscribe or unsubscribe via the World Wide Web, visit
        https://mail.mozilla.org/listinfo/es-discuss
or, via email, send a message with subject or body 'help' to
        [hidden email]

You can reach the person managing the list at
        [hidden email]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of es-discuss digest..."

Today's Topics:

   1. Re: Ranges (Jeremy Martin)
   2. Re: Ranges (Alexander Jones)
   3. Re: Destructuring object outside of var declaration (Jeff Walden)


---------- Forwarded message ----------
From: Jeremy Martin <[hidden email]>
To: Hikaru Nakashima <[hidden email]>
Cc: es-discuss <[hidden email]>
Date: Wed, 14 Dec 2016 11:55:02 -0500
Subject: Re: Ranges
While slightly more verbose, the previously suggested `...` syntax does have a superficial consistency with the spread operator. Both perform an expansion of sorts, which has a subtle elegance to it, IMO.

On Wed, Dec 14, 2016 at 4:02 AM, Hikaru Nakashima <[hidden email]> wrote:
I understand.
I hope to find a good form of literals.

Is there a fact that literals are easier to optimize in the following cases?

```
for (let i of [1 to 5]) { ...... }
vs
for (let i of Array.range(1, 5)) { ...... }
```

If so, it seems that we can attract vendors' interests.

2016-12-14 17:29 GMT+09:00 Andy Earnshaw <[hidden email]>:

I think you'd be lucky to even get to that stage.  Vendors aren't keen on any kind of backwards incompatibility in new specs and trying to get this to stage 4 with such a glaring one would be practically  impossible.

It's not just the incompatibility either.  You also introduce an inconsistencies where things like `[1..toFixed(2)]` doesn't mean the same as `[ 1..toFixed(2) ]`. That kind of thing is just confusing to developers.

When you consider these things, it becomes clear that it's not practical to change the language this way for such a small benefit.


On Wed, 14 Dec 2016, 03:00 Hikaru Nakashima, <[hidden email]> wrote:
Oh, I understood it.
It looks like serious problem, but it is may not actually.
If this spec change doesn't break web, we can introduce this idea?
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss




--
Jeremy Martin
<a href="tel:(661)%20312-3853" value="+16613123853" target="_blank">661.312.3853
@jmar777


---------- Forwarded message ----------
From: Alexander Jones <[hidden email]>
To: Hikaru Nakashima <[hidden email]>, Jeremy Martin <[hidden email]>
Cc: es-discuss <[hidden email]>
Date: Wed, 14 Dec 2016 20:28:37 +0000
Subject: Re: Ranges
IMO this is quite unnecessary syntax sugar. Python has everything you could need here without special syntax.

On Wed, 14 Dec 2016 at 16:55, Jeremy Martin <[hidden email]> wrote:
While slightly more verbose, the previously suggested `...` syntax does have a superficial consistency with the spread operator. Both perform an expansion of sorts, which has a subtle elegance to it, IMO.

On Wed, Dec 14, 2016 at 4:02 AM, Hikaru Nakashima <[hidden email]> wrote:
I understand.
I hope to find a good form of literals.

Is there a fact that literals are easier to optimize in the following cases?

```
for (let i of [1 to 5]) { ...... }
vs
for (let i of Array.range(1, 5)) { ...... }
```

If so, it seems that we can attract vendors' interests.

2016-12-14 17:29 GMT+09:00 Andy Earnshaw <[hidden email]>:

I think you'd be lucky to even get to that stage.  Vendors aren't keen on any kind of backwards incompatibility in new specs and trying to get this to stage 4 with such a glaring one would be practically  impossible.



It's not just the incompatibility either.  You also introduce an inconsistencies where things like `[1..toFixed(2)]` doesn't mean the same as `[ 1..toFixed(2) ]`. That kind of thing is just confusing to developers.



When you consider these things, it becomes clear that it's not practical to change the language this way for such a small benefit.




On Wed, 14 Dec 2016, 03:00 Hikaru Nakashima, <[hidden email]> wrote:
Oh, I understood it.
It looks like serious problem, but it is may not actually.
If this spec change doesn't break web, we can introduce this idea?


_______________________________________________


es-discuss mailing list


[hidden email]


https://mail.mozilla.org/listinfo/es-discuss








_______________________________________________


es-discuss mailing list


[hidden email]


https://mail.mozilla.org/listinfo/es-discuss






--
Jeremy Martin
<a href="tel:(661)%20312-3853" value="+16613123853" target="_blank">661.312.3853
@jmar777




_______________________________________________

es-discuss mailing list

[hidden email]

https://mail.mozilla.org/listinfo/es-discuss



---------- Forwarded message ----------
From: Jeff Walden <[hidden email]>
To: Isiah Meadows <[hidden email]>, Allen Wirfs-Brock <[hidden email]>
Cc: Nathan Wall <[hidden email]>, Brendan Eich <[hidden email]>, "[hidden email]" <[hidden email]>
Date: Wed, 14 Dec 2016 12:55:46 -0800
Subject: Re: Destructuring object outside of var declaration
On 11/13/2016 12:33 PM, Isiah Meadows wrote:
> Okay. Is it a spec bug then? Throwing a ReferenceError is surprising and odd IMHO.

I think so -- having different sorts of early errors makes it a little less clear what sort of error should be thrown when two early errors of different types are in the same script.  Last I knew, the spec was basically just waiting on someone to experiment with pulling the trigger to make everything a SyntaxError.  I've been meaning to do that for awhile, but it's not a high priority.

Jeff


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss



_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Proxy

Boris Zbarsky
On 12/14/16 8:47 PM, Uther Pendragon wrote:
> Perhaps it's a bit late... but I'd like to discuss the proxy object.
> Notably:  why no way to define a hook for when a property is called as a
> function.

See thread at <https://esdiscuss.org/topic/es6-proxy-function-call-trap>.

> I think I understand *why* there isn't one..  I presume because how a
> property is used (I.e. as a property or called as a function) is a level
> deeper than the recalling of said property.  If at all possible, I think
> it would be incredibly useful.

It's possible, in general; it was there in the proxy proposals at some
point, as the thread linked above says.  It leads to weird consequences
like "foo.bar()" behaving differently from "foo.bar.call(foo)" when
everyone expects them to be the same thing.

> I presume most implementations define scope
> variables much like object properties internally.

That's not clear to me at all.  In general, non-object environments
don't need to support all the operations objects do (e.g. you can't
delete bindings), so the implementation tradeoffs are quite different
and using a separate codepath for environments and object properties is
likely to be appropriate.  Certainly the one implementation for which I
know this details (SpiderMonkey) has quite different implementations for
scope variables and object properties.

-Boris
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Proxy

Andreas Rossberg-4
On 15 December 2016 at 03:26, Boris Zbarsky <[hidden email]> wrote:
I presume most implementations define scope
variables much like object properties internally.

That's not clear to me at all.  In general, non-object environments don't need to support all the operations objects do (e.g. you can't delete bindings), so the implementation tradeoffs are quite different and using a separate codepath for environments and object properties is likely to be appropriate.  Certainly the one implementation for which I know this details (SpiderMonkey) has quite different implementations for scope variables and object properties.

Indeed, the two couldn't be more different. In general, there isn't even a self-contained data structure representing a scope, let alone a unique one. Some variables might live in registers, some on the stack, some on the heap, some in several of those places at different points in time, some are optimised away entirely. Their names are not generally kept around either.

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Proxy

Isiah Meadows-2
In reply to this post by Uther Pendragon
You can always just return a callable from `handler.get`. Function closures are much more ergonomic than proxies for that in my experience, although I generally make no distinction regarding `this` (which only complicates in this area).

On Wed, Dec 14, 2016, 20:47 Uther Pendragon <[hidden email]> wrote:
Perhaps it's a bit late... but I'd like to discuss the proxy object.  Notably:  why no way to define a hook for when a property is called as a function.

I think I understand *why* there isn't one..  I presume because how a property is used (I.e. as a property or called as a function) is a level deeper than the recalling of said property.  If at all possible, I think it would be incredibly useful.  This may be outside the intended purpose of the proxy object, but a proxy for the purposes of a middleware (I hate that word too) that is more dynamic  would be perfect for adaptors etc...  Perhaps it's not feasible, because the proxy hook is best applied at the point when the property's definition, which brings me to my next suggestion....

What about the ability to alter / define the configuration of a scope variable, like those on objects with defineProperty... but with simple scope variables...  I presume most implementations define scope variables much like object properties internally.

On Dec 14, 2016 2:56 PM, <[hidden email]> wrote:
Send es-discuss mailing list submissions to
        [hidden email]

To subscribe or unsubscribe via the World Wide Web, visit
        https://mail.mozilla.org/listinfo/es-discuss
or, via email, send a message with subject or body 'help' to
        [hidden email]

You can reach the person managing the list at
        [hidden email]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of es-discuss digest..."

Today's Topics:

   1. Re: Ranges (Jeremy Martin)
   2. Re: Ranges (Alexander Jones)
   3. Re: Destructuring object outside of var declaration (Jeff Walden)


---------- Forwarded message ----------
From: Jeremy Martin <[hidden email]>
To: Hikaru Nakashima <[hidden email]>
Cc: es-discuss <[hidden email]>
Date: Wed, 14 Dec 2016 11:55:02 -0500
Subject: Re: Ranges
While slightly more verbose, the previously suggested `...` syntax does have a superficial consistency with the spread operator. Both perform an expansion of sorts, which has a subtle elegance to it, IMO.

On Wed, Dec 14, 2016 at 4:02 AM, Hikaru Nakashima <[hidden email]> wrote:
I understand.
I hope to find a good form of literals.

Is there a fact that literals are easier to optimize in the following cases?

```
for (let i of [1 to 5]) { ...... }
vs
for (let i of Array.range(1, 5)) { ...... }
```

If so, it seems that we can attract vendors' interests.

2016-12-14 17:29 GMT+09:00 Andy Earnshaw <[hidden email]>:

I think you'd be lucky to even get to that stage.  Vendors aren't keen on any kind of backwards incompatibility in new specs and trying to get this to stage 4 with such a glaring one would be practically  impossible.

It's not just the incompatibility either.  You also introduce an inconsistencies where things like `[1..toFixed(2)]` doesn't mean the same as `[ 1..toFixed(2) ]`. That kind of thing is just confusing to developers.

When you consider these things, it becomes clear that it's not practical to change the language this way for such a small benefit.


On Wed, 14 Dec 2016, 03:00 Hikaru Nakashima, <[hidden email]> wrote:
Oh, I understood it.
It looks like serious problem, but it is may not actually.
If this spec change doesn't break web, we can introduce this idea?
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss




--
Jeremy Martin
<a href="tel:(661)%20312-3853" value="+16613123853" class="gmail_msg" target="_blank">661.312.3853
@jmar777


---------- Forwarded message ----------
From: Alexander Jones <[hidden email]>
To: Hikaru Nakashima <[hidden email]>, Jeremy Martin <[hidden email]>
Cc: es-discuss <[hidden email]>
Date: Wed, 14 Dec 2016 20:28:37 +0000
Subject: Re: Ranges
IMO this is quite unnecessary syntax sugar. Python has everything you could need here without special syntax.

On Wed, 14 Dec 2016 at 16:55, Jeremy Martin <[hidden email]> wrote:
While slightly more verbose, the previously suggested `...` syntax does have a superficial consistency with the spread operator. Both perform an expansion of sorts, which has a subtle elegance to it, IMO.

On Wed, Dec 14, 2016 at 4:02 AM, Hikaru Nakashima <[hidden email]> wrote:
I understand.
I hope to find a good form of literals.

Is there a fact that literals are easier to optimize in the following cases?

```
for (let i of [1 to 5]) { ...... }
vs
for (let i of Array.range(1, 5)) { ...... }
```

If so, it seems that we can attract vendors' interests.

2016-12-14 17:29 GMT+09:00 Andy Earnshaw <[hidden email]>:

I think you'd be lucky to even get to that stage.  Vendors aren't keen on any kind of backwards incompatibility in new specs and trying to get this to stage 4 with such a glaring one would be practically  impossible.



It's not just the incompatibility either.  You also introduce an inconsistencies where things like `[1..toFixed(2)]` doesn't mean the same as `[ 1..toFixed(2) ]`. That kind of thing is just confusing to developers.



When you consider these things, it becomes clear that it's not practical to change the language this way for such a small benefit.




On Wed, 14 Dec 2016, 03:00 Hikaru Nakashima, <[hidden email]> wrote:
Oh, I understood it.
It looks like serious problem, but it is may not actually.
If this spec change doesn't break web, we can introduce this idea?


_______________________________________________


es-discuss mailing list


[hidden email]


https://mail.mozilla.org/listinfo/es-discuss








_______________________________________________


es-discuss mailing list


[hidden email]


https://mail.mozilla.org/listinfo/es-discuss






--
Jeremy Martin
<a href="tel:(661)%20312-3853" value="+16613123853" class="gmail_msg" target="_blank">661.312.3853
@jmar777




_______________________________________________

es-discuss mailing list

[hidden email]

https://mail.mozilla.org/listinfo/es-discuss



---------- Forwarded message ----------
From: Jeff Walden <[hidden email]>
To: Isiah Meadows <[hidden email]>, Allen Wirfs-Brock <[hidden email]>
Cc: Nathan Wall <[hidden email]>, Brendan Eich <[hidden email]>, "[hidden email]" <[hidden email]>
Date: Wed, 14 Dec 2016 12:55:46 -0800
Subject: Re: Destructuring object outside of var declaration
On 11/13/2016 12:33 PM, Isiah Meadows wrote:
> Okay. Is it a spec bug then? Throwing a ReferenceError is surprising and odd IMHO.

I think so -- having different sorts of early errors makes it a little less clear what sort of error should be thrown when two early errors of different types are in the same script.  Last I knew, the spec was basically just waiting on someone to experiment with pulling the trigger to make everything a SyntaxError.  I've been meaning to do that for awhile, but it's not a high priority.

Jeff


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Proxy

Uther Pendragon

Agreed, but it lacks intent...  I.e., the get handler doesn't know whether the return value is being called.

Imagine a layer that is so robust and flexible that, to use it, you don't have to know or care how the things are used...   You just do what makes sense and it works...  this concept kinda depends on knowing whether something is being called from, read or assigned when the handler is called.

On Dec 21, 2016 7:05 AM, "Isiah Meadows" <[hidden email]> wrote:
You can always just return a callable from `handler.get`. Function closures are much more ergonomic than proxies for that in my experience, although I generally make no distinction regarding `this` (which only complicates in this area).

On Wed, Dec 14, 2016, 20:47 Uther Pendragon <[hidden email]> wrote:
Perhaps it's a bit late... but I'd like to discuss the proxy object.  Notably:  why no way to define a hook for when a property is called as a function.

I think I understand *why* there isn't one..  I presume because how a property is used (I.e. as a property or called as a function) is a level deeper than the recalling of said property.  If at all possible, I think it would be incredibly useful.  This may be outside the intended purpose of the proxy object, but a proxy for the purposes of a middleware (I hate that word too) that is more dynamic  would be perfect for adaptors etc...  Perhaps it's not feasible, because the proxy hook is best applied at the point when the property's definition, which brings me to my next suggestion....

What about the ability to alter / define the configuration of a scope variable, like those on objects with defineProperty... but with simple scope variables...  I presume most implementations define scope variables much like object properties internally.

On Dec 14, 2016 2:56 PM, <[hidden email]> wrote:
Send es-discuss mailing list submissions to
        [hidden email]

To subscribe or unsubscribe via the World Wide Web, visit
        https://mail.mozilla.org/listinfo/es-discuss
or, via email, send a message with subject or body 'help' to
        [hidden email]

You can reach the person managing the list at
        [hidden email]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of es-discuss digest..."

Today's Topics:

   1. Re: Ranges (Jeremy Martin)
   2. Re: Ranges (Alexander Jones)
   3. Re: Destructuring object outside of var declaration (Jeff Walden)


---------- Forwarded message ----------
From: Jeremy Martin <[hidden email]>
To: Hikaru Nakashima <[hidden email]>
Cc: es-discuss <[hidden email]>
Date: Wed, 14 Dec 2016 11:55:02 -0500
Subject: Re: Ranges
While slightly more verbose, the previously suggested `...` syntax does have a superficial consistency with the spread operator. Both perform an expansion of sorts, which has a subtle elegance to it, IMO.

On Wed, Dec 14, 2016 at 4:02 AM, Hikaru Nakashima <[hidden email]> wrote:
I understand.
I hope to find a good form of literals.

Is there a fact that literals are easier to optimize in the following cases?

```
for (let i of [1 to 5]) { ...... }
vs
for (let i of Array.range(1, 5)) { ...... }
```

If so, it seems that we can attract vendors' interests.

2016-12-14 17:29 GMT+09:00 Andy Earnshaw <[hidden email]>:

I think you'd be lucky to even get to that stage.  Vendors aren't keen on any kind of backwards incompatibility in new specs and trying to get this to stage 4 with such a glaring one would be practically  impossible.

It's not just the incompatibility either.  You also introduce an inconsistencies where things like `[1..toFixed(2)]` doesn't mean the same as `[ 1..toFixed(2) ]`. That kind of thing is just confusing to developers.

When you consider these things, it becomes clear that it's not practical to change the language this way for such a small benefit.


On Wed, 14 Dec 2016, 03:00 Hikaru Nakashima, <[hidden email]> wrote:
Oh, I understood it.
It looks like serious problem, but it is may not actually.
If this spec change doesn't break web, we can introduce this idea?
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss




--
Jeremy Martin
<a href="tel:(661)%20312-3853" value="+16613123853" class="m_-1808569522584589473m_-2579292351032627970gmail_msg" target="_blank">661.312.3853
@jmar777


---------- Forwarded message ----------
From: Alexander Jones <[hidden email]>
To: Hikaru Nakashima <[hidden email]>, Jeremy Martin <[hidden email]>
Cc: es-discuss <[hidden email]>
Date: Wed, 14 Dec 2016 20:28:37 +0000
Subject: Re: Ranges
IMO this is quite unnecessary syntax sugar. Python has everything you could need here without special syntax.

On Wed, 14 Dec 2016 at 16:55, Jeremy Martin <[hidden email]> wrote:
While slightly more verbose, the previously suggested `...` syntax does have a superficial consistency with the spread operator. Both perform an expansion of sorts, which has a subtle elegance to it, IMO.

On Wed, Dec 14, 2016 at 4:02 AM, Hikaru Nakashima <[hidden email]> wrote:
I understand.
I hope to find a good form of literals.

Is there a fact that literals are easier to optimize in the following cases?

```
for (let i of [1 to 5]) { ...... }
vs
for (let i of Array.range(1, 5)) { ...... }
```

If so, it seems that we can attract vendors' interests.

2016-12-14 17:29 GMT+09:00 Andy Earnshaw <[hidden email]>:

I think you'd be lucky to even get to that stage.  Vendors aren't keen on any kind of backwards incompatibility in new specs and trying to get this to stage 4 with such a glaring one would be practically  impossible.



It's not just the incompatibility either.  You also introduce an inconsistencies where things like `[1..toFixed(2)]` doesn't mean the same as `[ 1..toFixed(2) ]`. That kind of thing is just confusing to developers.



When you consider these things, it becomes clear that it's not practical to change the language this way for such a small benefit.




On Wed, 14 Dec 2016, 03:00 Hikaru Nakashima, <[hidden email]> wrote:
Oh, I understood it.
It looks like serious problem, but it is may not actually.
If this spec change doesn't break web, we can introduce this idea?


_______________________________________________


es-discuss mailing list


[hidden email]


https://mail.mozilla.org/listinfo/es-discuss








_______________________________________________


es-discuss mailing list


[hidden email]


https://mail.mozilla.org/listinfo/es-discuss






--
Jeremy Martin
<a href="tel:(661)%20312-3853" value="+16613123853" class="m_-1808569522584589473m_-2579292351032627970gmail_msg" target="_blank">661.312.3853
@jmar777




_______________________________________________

es-discuss mailing list

[hidden email]

https://mail.mozilla.org/listinfo/es-discuss



---------- Forwarded message ----------
From: Jeff Walden <[hidden email]>
To: Isiah Meadows <[hidden email]>, Allen Wirfs-Brock <[hidden email]>
Cc: Nathan Wall <[hidden email]>, Brendan Eich <[hidden email]>, "[hidden email]" <[hidden email]>
Date: Wed, 14 Dec 2016 12:55:46 -0800
Subject: Re: Destructuring object outside of var declaration
On 11/13/2016 12:33 PM, Isiah Meadows wrote:
> Okay. Is it a spec bug then? Throwing a ReferenceError is surprising and odd IMHO.

I think so -- having different sorts of early errors makes it a little less clear what sort of error should be thrown when two early errors of different types are in the same script.  Last I knew, the spec was basically just waiting on someone to experiment with pulling the trigger to make everything a SyntaxError.  I've been meaning to do that for awhile, but it's not a high priority.

Jeff


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss