Re: [Harmony proxies] Discussion on the declarative object experiment

2011-04-13 Thread Dmitry A. Soshnikov
On 12.04.2011 20:41, David Bruant wrote: Hi, I'd like to share my experience on a recent experiment. First off, I'd like to apologize for the name; declarative object doesn't really capture it and may be confusing. Second of all, what I have created doesn't really solve any use case (I'll

Re: [Harmony proxies] Discussion on the declarative object experiment

2011-04-13 Thread David Bruant
Le 12/04/2011 18:41, David Bruant a écrit : Hi, I'd like to share my experience on a recent experiment. First off, I'd like to apologize for the name; declarative object doesn't really capture it and may be confusing. Second of all, what I have created doesn't really solve any use case (I'll

Re: [Harmony proxies] Discussion on the declarative object experiment

2011-04-13 Thread Dmitry A. Soshnikov
On 13.04.2011 12:08, David Bruant wrote: Le 13/04/2011 09:02, Dmitry A. Soshnikov a écrit : On 12.04.2011 20:41, David Bruant wrote: Hi, I'd like to share my experience on a recent experiment. First off, I'd like to apologize for the name; declarative object doesn't really capture it and

Re: [Harmony proxies] Discussion on the declarative object experiment

2011-04-13 Thread David Bruant
Le 13/04/2011 10:18, Dmitry A. Soshnikov a écrit : On 13.04.2011 12:08, David Bruant wrote: Le 13/04/2011 09:02, Dmitry A. Soshnikov a écrit : Yes, the pattern is interesting, though, really, which practical use-case will it have? I warned from the beginning that I didn't see any :-p More

Re: 'this' is more complicated than I thought (PropertyReferencesbreak equivalences)

2011-04-13 Thread Claus Reinke
The behavior of References isn't as arbitrary or different from other languages as it might seem. It's really a way to specify l-values. Not arbitrary, but different, and quite drastically so (as far as usage is concerned). Your remarks helped me to pin down the difference (and eliminated two

Re: 'this' is more complicated than I thought (PropertyReferences break equivalences)

2011-04-13 Thread Claus Reinke
Like most Javascript programmers, I have tended to follow a simple rule for functions using 'this': eta-expand method selections, use .bind, or get into trouble. That is unnecessary, inefficient, and adds clutter. The problem with rules-of-thumb is that most people only have two of those;-) I

Re: value proxies, fundamental traps for binary operators, precedence

2011-04-13 Thread Claus Reinke
finding relevant information on the wiki isn't straightforward for newcomers. Good point, operators in particular need some navigational help. I'll do something about it. Thanks. Btw, other things I've been looking for are timeline, process, committee information, and software information

Re: Escaping of / in JSON

2011-04-13 Thread Lasse Reichstein
On Wed, 13 Apr 2011 07:30:58 +0200, Oliver Hunt oli...@apple.com wrote: It has recently been brought to my attention that a particular use case of JSON serialisation is to include JSON serialised content directly into an HTML file (inside a script tag). In this case in addition to the

Existential operator

2011-04-13 Thread Dmitry A. Soshnikov
Hi, (I separate it from recent thread on shared handlers for proxies). The existential operator is a syntactic sugar to avoid long testing whether a property exists and only after that to apply it. This already is again used in CoffeeScript, so I'll show the examples: let street =

Re: Existential operator

2011-04-13 Thread Brendan Eich
See http://wiki.ecmascript.org/doku.php?id=strawman:default_operator -- the proposal there is ?? and ??= since single ? is ambiguous after an expression due to conditional expressions (?:). On Apr 13, 2011, at 11:37 AM, Dmitry A. Soshnikov wrote: let street = user.address?.street which

Re: Escaping of / in JSON

2011-04-13 Thread Kyle Simpson
Many JSON serializer implementations escape the / character, including for instance PHP's json_encode(). However, JavaScript's own JSON.stringify() does not. If you look at the grammar on json.org, as I read it, the escaping of / is **optional**, since it is a valid UNICODE character, and it's

Re: Existential operator

2011-04-13 Thread Kyle Simpson
See http://wiki.ecmascript.org/doku.php?id=strawman:default_operator -- the proposal there is ?? and ??= since single ? is ambiguous after an expression due to conditional expressions (?:). The default operator doesn't address a significant part of what Dmitry is asking for -- the . in the

Uniform proxy API via caching call and construct traps

2011-04-13 Thread Sean Eagan
Hi, When the uniform proxy API [1] was being explored, was it ever considered to just cache the call and construct traps within the proxy during the Proxy.create() call rather than look them up each time the proxy is called as a function or constructor? That seems to solve most if not all of the

Re: Existential operator

2011-04-13 Thread Garrett Smith
On 4/13/11, Kyle Simpson get...@gmail.com wrote: See http://wiki.ecmascript.org/doku.php?id=strawman:default_operator -- the proposal there is ?? and ??= since single ? is ambiguous after an expression due to conditional expressions (?:). The default operator doesn't address a significant

Re: Existential operator

2011-04-13 Thread Kyle Simpson
The other (more awkward/obscure looking) way to do this is: var a; b a = c; a = b c; That is not the same thing. Your code assigns `b` to `a` if `b` is falsy . The other code either leaves `a` as undefined (strictly doesn't assign) if the test fails, or assigns it the value of `c` (no

Re: Existential operator

2011-04-13 Thread Brendan Eich
On Apr 13, 2011, at 3:38 PM, Kyle Simpson wrote: See http://wiki.ecmascript.org/doku.php?id=strawman:default_operator -- the proposal there is ?? and ??= since single ? is ambiguous after an expression due to conditional expressions (?:). The default operator doesn't address a

Re: Existential operator

2011-04-13 Thread Brendan Eich
On Apr 13, 2011, at 7:51 PM, Kyle Simpson wrote: Your suggestion to change the ternary operator is interesting but creates incompatibility. It is not feasible. I'm curious what incompatibility you mean? If we're talking about backwards compatibility... of course. But a lot of the

Re: Existential operator

2011-04-13 Thread Dmitry A. Soshnikov
On 13.04.2011 16:57, Brendan Eich wrote: See http://wiki.ecmascript.org/doku.php?id=strawman:default_operator -- the proposal there is ?? and ??= since single ? is ambiguous after an expression due to conditional expressions (?:). On Apr 13, 2011, at 11:37 AM, Dmitry A. Soshnikov wrote: let

Re: Existential operator

2011-04-13 Thread Dmitry A. Soshnikov
On 13.04.2011 17:38, Kyle Simpson wrote: See http://wiki.ecmascript.org/doku.php?id=strawman:default_operator -- the proposal there is ?? and ??= since single ? is ambiguous after an expression due to conditional expressions (?:). The default operator doesn't address a significant part of

Re: Existential operator

2011-04-13 Thread Dmitry A. Soshnikov
On 13.04.2011 21:57, Brendan Eich wrote: On Apr 13, 2011, at 3:38 PM, Kyle Simpson wrote: See http://wiki.ecmascript.org/doku.php?id=strawman:default_operator -- the proposal there is ?? and ??= since single ? is ambiguous after an expression due to conditional expressions (?:). The

Re: Existential operator

2011-04-13 Thread Brendan Eich
On Apr 13, 2011, at 8:04 PM, Dmitry A. Soshnikov wrote: var a = b ? c; // aka, `var a = b ? c : undefined` Hm, intuitively the form `a = b ? c` sounds for me as: a = b ? b : c Which would be a = b || c; or if you want to test exactly b === undefined, a = b ?? c; but this

Re: Existential operator

2011-04-13 Thread Brendan Eich
On Apr 13, 2011, at 8:01 PM, Dmitry A. Soshnikov wrote: (regardless that ES6 will have compile-time bindings, it still possible to create global var at runtime via `this.bar`, though, if there will be no global object, I'm not sure how this applies to the ES6) No, Harmony won't alias this

Re: Existential operator

2011-04-13 Thread Brendan Eich
On Apr 13, 2011, at 8:25 PM, Brendan Eich wrote: is too noisy in contrast with: foo.bar?.baz?quax(value); and first of all, this syntactic sugar is proposed exactly this such cases. Did you leave out a . after the second . in that example? Er, after the second ? in that example? /be

Re: Escaping of / in JSON

2011-04-13 Thread Mike Samuel
2011/4/12 Oliver Hunt oli...@apple.com: It has recently been brought to my attention that a particular use case of JSON serialisation is to include JSON serialised content directly into an HTML file (inside a script tag).  In this case in addition to the threat of strings being terminated

Re: Existential operator

2011-04-13 Thread Brendan Eich
I declare this whole no-space-suffix idea a bad path and renounce it. Again, CoffeeScript is its own (informally specified) language (Jeremy is awesome). However: we should learn from it but not blindly copy from it. /be On Apr 13, 2011, at 8:42 PM, Bob Nystrom wrote: OTOH, if ? as an

Re: Existential operator

2011-04-13 Thread Dmitry A. Soshnikov
On 13.04.2011 22:25, Brendan Eich wrote: On Apr 13, 2011, at 8:01 PM, Dmitry A. Soshnikov wrote: (regardless that ES6 will have compile-time bindings, it still possible to create global var at runtime via `this.bar`, though, if there will be no global object, I'm not sure how this applies to

Re: Existential operator

2011-04-13 Thread David Herman
It'll be the WindowProxy as usual, in top level code. Dave has addressed what it will be in a module recently. I have to look on Dave's explanation, seems I missed it. But this WindowProxy won't be assessable then, right? Will it be possible to define a new global property/variable at

Re: Existential operator

2011-04-13 Thread Kyle Simpson
See http://wiki.ecmascript.org/doku.php?id=strawman:default_operator -- the proposal there is ?? and ??= since single ? is ambiguous after an expression due to conditional expressions (?:). The default operator doesn't address a significant part of what Dmitry is asking for -- the . in the

Re: Existential operator

2011-04-13 Thread Brendan Eich
On Apr 13, 2011, at 8:46 PM, Dmitry A. Soshnikov wrote: I had dinner with Jeremy Ashkenas last month, and he testified that CoffeeScript's disamgibuator pass (between lexing and parsing) is a work in progress and a work of (literately programmed) random logic, which he has tweaked based on

Re: Existential operator

2011-04-13 Thread Brendan Eich
On Apr 13, 2011, at 9:21 PM, Kyle Simpson wrote: First, making : optional introduces a dangling-else ambiguity: x = a ? b ? c : d; This could be (x = a ? (b ? c : d)) or (x = a ? (b ? c) : d). True, if-else already has this (traditional in C-based languages) ambiguity, resolved by

Re: Existential operator

2011-04-13 Thread Brendan Eich
On Apr 13, 2011, at 9:06 PM, David Herman wrote: It'll be the WindowProxy as usual, in top level code. Dave has addressed what it will be in a module recently. I have to look on Dave's explanation, seems I missed it. But this WindowProxy won't be assessable then, right? Will it be

Optional : in ?: operator [was: Existential operator]

2011-04-13 Thread Kyle Simpson
I'm not sure I see how this is really introducing an additional ambiguity? It is obviously introducing an ambiguity where none exists today. ?: is indivisible, unlike if vs. if else. I was referring to no additional visual ambiguity inside the ?: with respect to operator precedence and how

Re: Existential operator

2011-04-13 Thread David Herman
Cool -- is this spec'ed yet? http://wiki.ecmascript.org/doku.php?id=harmony:modules#this Dave ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Optional : in ?: operator [was: Existential operator]

2011-04-13 Thread Brendan Eich
On Apr 13, 2011, at 10:46 PM, Kyle Simpson wrote: I'm not sure I see how this is really introducing an additional ambiguity? It is obviously introducing an ambiguity where none exists today. ?: is indivisible, unlike if vs. if else. I was referring to no additional visual ambiguity

Re: Optional : in ?: operator [was: Existential operator]

2011-04-13 Thread David Herman
I don't think this feature is worth all this discussion or time, which is why I haven't said very much. But I don't like the idea. It *is* ambiguous, in the sense that if you wrote the grammar in the natural way it would be an ambiguous grammar, so you have to rewrite the grammar in such a way

Shared proxy handlers

2011-04-13 Thread Sean Eagan
One way to get truly shared proxy handlers would be to allow proxies to have some internal instance state that gets passed to each trap, just like objects have internal instance state ( [[Prototype]], [[Class]], [[Extensible]] etc) that gets passed to their traps ( [[Get]], [[GetOwnProperty]],

Re: Optional : in ?: operator [was: Existential operator]

2011-04-13 Thread Kyle Simpson
In an LR(1) grammar, if vs. if-else or ? vs. ?: is a shift-reduce conflict (to use yacc terms). It is an ambiguity. It can be disambiguated, but please do not confuse disambiguation via shifting with no *real* ambiguity. My point is it IS disambiguated by the definition of operator

Re: Optional : in ?: operator [was: Existential operator]

2011-04-13 Thread Kyle Simpson
Brendan, you've asked for other coding examples where I use the pattern of some variable being `undefined` or not to trigger different behavior (that is, to use the variable or not). Here's two more: 1. I have a templating engine DSL (called HandlebarJS) I wrote (in JS), which includes a

Re: Optional : in ?: operator [was: Existential operator]

2011-04-13 Thread Brendan Eich
On Apr 14, 2011, at 12:00 AM, Kyle Simpson wrote: It's also not obviously a good non-hard case to burn into the grammar. What is non-hard about saying that, in the processing of any ?: expression, if the ? is present but the : is not found where it is expected, then the : is implied and