-----Original Message----- From: Brendan Eich
Sent: Monday, November 22, 2010 4:10 PM
To: Allen Wirfs-Brock
Cc: Oliver Hunt ; es-discuss
Subject: Re: Nov 18 notes

On Nov 22, 2010, at 3:17 PM, Allen Wirfs-Brock wrote:
...

enum key with keys(x) {

This is a clever homage to "with" :-P.

AWB: actually, when I made this up I was a bit concerned using "with" because of its heritage. I got over it...

The parenthesis-free head is unusual and invites Go-like innovation elsewhere: will Harmony drop mandatory parens around if, while, etc. heads?

AWB: Since what comes immediately after "enum" is a declaration from there isn't any precedent for parens there. They could be added after the "with" if that felt more familiar.

Iteration is not numbering or naming, so taking enum for this purpose promulgates a misnomer *and* precludes us using enum for a categorical sum declaration of some sort.

AWB: See my reply to Dave Herman on this issue.


2) Whenever possible, less general pre-existing syntactic forms should be redefined to desugar into new more general forms.

ES1-5 for-in can be defined via desugaring to enum-with, for example:

//desugar:   for (var x in foo) {alert(foo[x])}
var x;
enum __x with __ES5forinEnumerator(x) {
 x=__x;
 {alert(foo[x])}
}

This goes against the Proxy design. A proxy shouldn't have to special case __ES5forinEnumerator to customize for-in as opposed to enum-with, and customizing for-in should not affect enum-with when up the proto chain as one of my recent posts showed with a js shell session.

AWB: Perhaps and we have other use cases of property name enumeration (Object.key and getOwnPropertyNames, the in operator) that may need the enumerate trap. I know that trap design was one of the starting points of this discussion so I probably should look more closely at this.

If we must have new syntax to get customized iteration through TC39, we can spend way too much time coming up with acceptable syntax. But before we dive into that fun timekilling process, let's be really sure we are not missing the forest for the trees.

AWB: For what it's worth, in the Northwest we have a long tradition of cutting down trees and then latter realizing that we don't have a forest any more...

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

Reply via email to