Re: return when desugaring to closures

2008-10-21 Thread Brendan Eich
Followup to discuss some open issues from the thread, evident in the message cited below: 1. Unifying var scope and let scope at top level of a function could be done, with tolerable restrictions: given let x at top level in a function body, existence of formal parameter x, and

Re: return when desugaring to closures

2008-10-21 Thread Waldemar Horwat
Brendan Eich wrote: Followup to discuss some open issues from the thread, evident in the message cited below: 1. Unifying var scope and let scope at top level of a function could be done, with tolerable restrictions: given let x at top level in a function body, existence of formal

Re: return when desugaring to closures

2008-10-21 Thread Mark S. Miller
On Tue, Oct 21, 2008 at 3:42 PM, Waldemar Horwat [EMAIL PROTECTED] wrote: What does ES3.1 do if you have both const x and var x at the top level? It just so happens that we discussed top level const in this morning's ES3.1 phone meeting. It never occurred to us to ban top level const. We did

Re: return when desugaring to closures

2008-10-21 Thread David-Sarah Hopwood
Mark S. Miller wrote: On Tue, Oct 21, 2008 at 3:42 PM, Waldemar Horwat [EMAIL PROTECTED] wrote: What does ES3.1 do if you have both const x and var x at the top level? It just so happens that we discussed top level const in this morning's ES3.1 phone meeting. It never occurred to us to ban

Re: return when desugaring to closures

2008-10-21 Thread Brendan Eich
On Oct 21, 2008, at 5:56 PM, David-Sarah Hopwood wrote: If we got in wrong in ES3.1, we couldn't fix it later. That's true, but I still hope to convince you and the group that we can get it right for ES3.1. With zero implementations due to lack of a spec that hangs together in full,

Re: return when desugaring to closures

2008-10-20 Thread Waldemar Horwat
Eric Suen wrote: I think top-down parser has no issue to parse following code: function() { }(); but this is not a valid statement because: ExpressionStatement ::= [lookahead ! {{, function}] Expression ; There is a good reason for that. It's because of semicolon insertion. You'd

Re: return when desugaring to closures

2008-10-17 Thread Waldemar Horwat
Brendan Eich wrote: On Oct 16, 2008, at 7:04 PM, Waldemar Horwat wrote: The parser is required to backtrack until it either finds an expansion of the grammar that doesn't generate a syntax error or until it discovers that they all do. You can choose to make additional syntax errors as

Re: return when desugaring to closures

2008-10-17 Thread Waldemar Horwat
Maciej Stachowiak wrote: I think it might be better to write the official ES3.1 grammar in this way, even though it is a little annoying and repetitive, so it can more readily be verified that the language grammar has no ambiguities by running through a parser-generator like yacc or bison

Re: return when desugaring to closures

2008-10-17 Thread Brendan Eich
On Oct 17, 2008, at 11:05 AM, Waldemar Horwat wrote: Brendan Eich wrote: Is this a perfectly valid for-in statement? for (a = b in c); Not according to ES3's grammar. An assignment expression is not valid on the left of the for-in's in: /IterationStatement /*:* * ...* *

Re: return when desugaring to closures

2008-10-17 Thread Brendan Eich
On Oct 17, 2008, at 11:30 AM, Brendan Eich wrote: In that case the -NoIn sub-grammar should apply, extended to LetExpressionNoIn. So for (let (a = b) c in d); Sorry, of course that should have been for (var a = let (b = c) b in d); /be ___

Re: return when desugaring to closures

2008-10-17 Thread Brendan Eich
On Oct 16, 2008, at 3:40 PM, Brendan Eich wrote: For now I favor the lambda expression form as well as the lambda block form. Good thing I added For now. Since I'm convinced by Waldemar's argument against ambiguity, I have to drop support for the lambda expression form. It could be

Re: return when desugaring to closures

2008-10-17 Thread Maciej Stachowiak
On Oct 17, 2008, at 11:17 AM, Waldemar Horwat wrote: Maciej Stachowiak wrote: As to the else issue, I don't think that ambiguity can be avoided, but bison lets you solve that with %nonassoc, which is a sound disambiguation mechanism. It can. I have a machine-validated ES3 (and ES4

Re: return when desugaring to closures

2008-10-17 Thread Eric Suen
The parser is required to backtrack until it either finds an expansion of the grammar that doesn't generate a syntax error or until it discovers that they all do. You can choose to make additional syntax errors as per chapter 16, but that does not relieve you of the backtracking requirement.

Re: return when desugaring to closures

2008-10-17 Thread Brendan Eich
On Oct 17, 2008, at 7:36 PM, Eric Suen wrote: Are you sure about that, because you using hand written top-down parser, Is it confirmed by a top-down parser generator like ANTLR? I haven't used ANTLR or any other LL(*) parser generator, no. I found http://code.google.com/p/antlr-javascript/

Re: return when desugaring to closures

2008-10-16 Thread Waldemar Horwat
Brendan Eich wrote: On Oct 15, 2008, at 2:36 PM, Waldemar Horwat wrote: There is no such thing as a let expression. Let expressions http://developer.mozilla.org/en/New_in_JavaScript_1.7#let_expressions in JS1.7 (Firefox 2+), based on the ES4 proposal

Re: return when desugaring to closures

2008-10-16 Thread Waldemar Horwat
Brendan Eich wrote: On Oct 16, 2008, at 11:38 AM, Waldemar Horwat wrote: Brendan Eich wrote: That's not a valid grammar. It is unambiguous. How do you define valid? You can't have an AssignmentExpression terminating a PrimaryExpression. It leads to trouble such as: let a = b + c

Re: return when desugaring to closures

2008-10-16 Thread Mark S. Miller
On Wed, Oct 15, 2008 at 4:49 PM, Dave Herman [EMAIL PROTECTED] wrote: In the grammar for proposed ES4, LetExpression was under PrimaryExpression. That's where I'm suggesting LambdaExpression might fit. IOW: PrimaryExpression ::= ... | LetExpression |

Re: return when desugaring to closures

2008-10-16 Thread Brendan Eich
On Oct 16, 2008, at 1:20 PM, Waldemar Horwat wrote: I don't think you can come up with a consistent shift or greedy notion. Funny, yacc has had one for decades, used to resolve dangling-else. The one you may be thinking of will happily accept code such as let (a = 5) x + y.foo = 2; yet

Re: return when desugaring to closures

2008-10-16 Thread Brendan Eich
On Oct 15, 2008, at 1:28 PM, Mark S. Miller wrote: On Wed, Oct 15, 2008 at 12:31 PM, Dave Herman [EMAIL PROTECTED] wrote: Do you prefer (lambda Formals Block | lambda Formals Expression)? [Personally I'm fine with that.] Or do you oppose any lambda expressions at all? Or did you have

Re: return when desugaring to closures

2008-10-16 Thread Brendan Eich
On Oct 16, 2008, at 3:33 PM, Brendan Eich wrote: SpiderMonkey historically used SyntaxError, not ReferenceError, and throw at compile-time. This pre-dates ES1. Another example not involving let expressions: js a + b = c typein:1: SyntaxError: invalid assignment left-hand side:

Re: return when desugaring to closures

2008-10-16 Thread David-Sarah Hopwood
Mark S. Miller wrote: On Wed, Oct 15, 2008 at 4:49 PM, Dave Herman [EMAIL PROTECTED] wrote: In the grammar for proposed ES4, LetExpression was under PrimaryExpression. That's where I'm suggesting LambdaExpression might fit. IOW: PrimaryExpression ::= ... | LetExpression

Re: return when desugaring to closures

2008-10-16 Thread Waldemar Horwat
Brendan Eich wrote: On Oct 16, 2008, at 1:20 PM, Waldemar Horwat wrote: I don't think you can come up with a consistent shift or greedy notion. Funny, yacc has had one for decades, used to resolve dangling-else. The one you may be thinking of will happily accept code such as let (a

Re: return when desugaring to closures

2008-10-16 Thread Mark S. Miller
On Thu, Oct 16, 2008 at 5:49 PM, David-Sarah Hopwood [EMAIL PROTECTED] wrote: [lots of good stuff snipped] I agree. The degenerate syntax let {...} allowed by this grammar at first-sight doesn't seem very useful, until you realize that it has a similar effect (apart from not preventing

Re: return when desugaring to closures

2008-10-16 Thread Maciej Stachowiak
On Oct 16, 2008, at 7:01 PM, Brendan Eich wrote: On Oct 16, 2008, at 3:33 PM, Brendan Eich wrote: On Oct 16, 2008, at 1:20 PM, Waldemar Horwat wrote: I don't think you can come up with a consistent shift or greedy notion. Funny, yacc has had one for decades, used to resolve

Re: return when desugaring to closures

2008-10-15 Thread Dave Herman
Please specify what you are proposing. The one proposal I've seen is: Expression ::= ... | lambda Formals Statement Yes, that's what I meant, or at least what I thought Yuh-Ruey meant. This is not particularly useful because then even assign a lambda to a variable would be a syntax

Re: return when desugaring to closures

2008-10-15 Thread Waldemar Horwat
Dave Herman wrote: Please specify what you are proposing. The one proposal I've seen is: Expression ::= ... | lambda Formals Statement Yes, that's what I meant, or at least what I thought Yuh-Ruey meant. This is not particularly useful because then even assign a lambda to a variable

Re: return when desugaring to closures

2008-10-15 Thread liorean
Please specify what you are proposing. The one proposal I've seen is: Expression ::= ... | lambda Formals Statement Dave Herman wrote: Yes, that's what I meant, or at least what I thought Yuh-Ruey meant. This is not particularly useful because then even assign a lambda to a variable

Re: return when desugaring to closures

2008-10-15 Thread Brendan Eich
On Oct 15, 2008, at 2:36 PM, Waldemar Horwat wrote: There is no such thing as a let expression. Let expressions in JS1.7 (Firefox 2+), based on the ES4 proposal. ES3- ish grammar: LetExpression : let ( VariableDeclarationList ) [lookahead ∉ {{}] AssignmentExpression produced from

Re: return when desugaring to closures

2008-10-15 Thread Brendan Eich
On Oct 15, 2008, at 6:13 PM, Brendan Eich wrote: On Oct 15, 2008, at 2:36 PM, Waldemar Horwat wrote: There is no such thing as a let expression. Let expressions in JS1.7 (Firefox 2+), based on the ES4 proposal. ES3-ish grammar: LetExpression : let ( VariableDeclarationList )

Re: return when desugaring to closures

2008-10-14 Thread Neil Mix
On Oct 13, 2008, at 6:39 PM, Brendan Eich wrote: Users may be modeling closures as capturing bindings, not scope chains of mutable objects, one per for (let...) statement or explicitly braced block. If so, could we make let declaration capture this way? Again, I'm proceeding from real users'

Re: return when desugaring to closures

2008-10-14 Thread David-Sarah Hopwood
David-Sarah Hopwood wrote: Neil Mix wrote: The for/closures bug is definitely a newbie trap, but its pain is not its discovery, but the difficulty of working around it. To me this could be a winning argument against re-binding on each loop, since re-binding precludes the (admittedly

Re: return when desugaring to closures

2008-10-14 Thread Brendan Eich
On Oct 14, 2008, at 7:38 AM, Neil Mix wrote: On Oct 13, 2008, at 6:39 PM, Brendan Eich wrote: Users may be modeling closures as capturing bindings, not scope chains of mutable objects, one per for (let...) statement or explicitly braced block. If so, could we make let declaration capture

Re: return when desugaring to closures

2008-10-14 Thread Neil Mix
What about for-in loops? I'm proceeding from user expectations being confounded. Something needs help here, possibly not for (;;) loops -- but almost certainly for-in loops containing closures capturing the loop variable. Whatever is done should be consistent between for and for-in. My

Re: return when desugaring to closures

2008-10-14 Thread P T Withington
On 2008-10-11, at 08:34EDT, David Herman wrote: Thank you for pointing out, though, that try/catch isn't so easily defined on top of return-to-label, since it still needs special handling for finally. The options are either to define a lower-level primitive underlying try/finally (akin

Re: return when desugaring to closures

2008-10-14 Thread Waldemar Horwat
Brendan Eich wrote: What did you mean by had better fail to compile? Other than the type annotation, there is nothing about function f() { x = 15; ... var t = some_runtime_expression; ... var x:t = ... } that ought to fail to compile. The assignment to x in that temporal dead

Re: return when desugaring to closures

2008-10-14 Thread Waldemar Horwat
David-Sarah Hopwood wrote: David-Sarah Hopwood wrote: Waldemar Horwat wrote: I am talking about let bindings. Lars brought up at that meeting. I did not find the use cases particularly convincing, but the dead zone is compelling. There are four ways to do this: A1. Lexical dead zone.

Re: return when desugaring to closures

2008-10-14 Thread David-Sarah Hopwood
Neil Mix wrote: The for/closures bug is definitely a newbie trap, but its pain is not its discovery, but the difficulty of working around it. To me this could be a winning argument against re-binding on each loop, since re-binding precludes the (admittedly dubious) use-case of

Re: return when desugaring to closures

2008-10-13 Thread David-Sarah Hopwood
Mark S. Miller wrote: On Sun, Oct 12, 2008 at 7:55 PM, David-Sarah Hopwood [EMAIL PROTECTED] wrote: In ES3.1, this will mean that they normally require braces whenever a body can introduce variables. There are two classes of exceptions, shown by these examples: a) while (...) foo: var x =

Re: return when desugaring to closures

2008-10-13 Thread Mark S. Miller
On Mon, Oct 13, 2008 at 8:05 AM, David-Sarah Hopwood [EMAIL PROTECTED] wrote: for (var ...) implicitly introduces a block whether or not it is a substatement. This is a wart of C++/C99/Java syntax that we have to live with, since too much code relies on it. Yes, but how do we live with it? The

Re: return when desugaring to closures

2008-10-13 Thread Jon Zeppieri
On Mon, Oct 13, 2008 at 11:43 AM, Mark S. Miller [EMAIL PROTECTED] wrote: On Mon, Oct 13, 2008 at 8:05 AM, David-Sarah Hopwood [EMAIL PROTECTED] wrote: for (var ...) implicitly introduces a block whether or not it is a substatement. This is a wart of C++/C99/Java syntax that we have to live

Re: return when desugaring to closures

2008-10-13 Thread Mark Miller
On Mon, Oct 13, 2008 at 9:13 AM, Jon Zeppieri [EMAIL PROTECTED] wrote: I like your intention here -- I brought up the iteration variable / closure issue earlier in the thread -- but this seems rather messy. In the 'var' case, x must be the same throughout, no? yes. function foo() { for

Re: return when desugaring to closures

2008-10-13 Thread Jon Zeppieri
On Mon, Oct 13, 2008 at 12:47 PM, Mark Miller [EMAIL PROTECTED] wrote: On Mon, Oct 13, 2008 at 9:13 AM, Jon Zeppieri [EMAIL PROTECTED] wrote: But then it becomes extremely awkward for the 'let' or 'const' case to use a fresh variable on every iteration. It ties the semantics of 'for' to its

Re: return when desugaring to closures

2008-10-13 Thread David-Sarah Hopwood
Mark S. Miller wrote: On Mon, Oct 13, 2008 at 8:05 AM, David-Sarah Hopwood [EMAIL PROTECTED] wrote: for (var ...) implicitly introduces a block whether or not it is a substatement. This is a wart of C++/C99/Java syntax that we have to live with, since too much code relies on it. Yes, but

Re: return when desugaring to closures

2008-10-13 Thread David-Sarah Hopwood
David-Sarah Hopwood wrote: Mark S. Miller wrote: But what about let. Do we all agree that in for (let x = ...) {...x...} ... x ... the x after the for loop does not refer to the x defined by the for loop? Yes, if this form is allowed. The other options are either to require:

Re: return when desugaring to closures

2008-10-13 Thread Brendan Eich
On Oct 13, 2008, at 8:43 AM, Mark S. Miller wrote: On Mon, Oct 13, 2008 at 8:05 AM, David-Sarah Hopwood [EMAIL PROTECTED] wrote: for (var ...) implicitly introduces a block whether or not it is a substatement. This is a wart of C++/C99/Java syntax that we have to live with, since too much

Re: return when desugaring to closures

2008-10-13 Thread Waldemar Horwat
Brendan Eich wrote: After some experiments, we decided for ES4 to make let and var the same at top level in a function or global code. This helped avoid implementation pain: very long scripts on the web, consisting of many statements in a row, motivate statement-wise parsing and

Re: return when desugaring to closures

2008-10-13 Thread Waldemar Horwat
Brendan Eich wrote: The agreement from the May TC39 meeting was that the declarations implicit (:*) and explicit annotations must normalize to the same type, or there's an error. That was back when the language had lots of requirements for compile-time expressions, including on all types.

Re: return when desugaring to closures

2008-10-13 Thread Brendan Eich
On Oct 13, 2008, at 3:51 PM, Waldemar Horwat wrote: Brendan Eich wrote: After some experiments, we decided for ES4 to make let and var the same at top level in a function or global code. This helped avoid implementation pain: very long scripts on the web, consisting of many statements in a

Re: return when desugaring to closures

2008-10-13 Thread Brendan Eich
On Oct 13, 2008, at 3:56 PM, Waldemar Horwat wrote: Brendan Eich wrote: The agreement from the May TC39 meeting was that the declarations implicit (:*) and explicit annotations must normalize to the same type, or there's an error. That was back when the language had lots of requirements for

Re: return when desugaring to closures

2008-10-13 Thread Waldemar Horwat
Brendan Eich wrote: If using an uninitialized let binding is an error, then hoisting is pointless except to make the statements between start of block and the let declaration a dead zone for the binding name. This fits the ancient, weak but not entirely worthless post-hoc rationale for

Re: return when desugaring to closures

2008-10-13 Thread Brendan Eich
On Oct 13, 2008, at 4:01 PM, Waldemar Horwat wrote: Brendan Eich wrote: If using an uninitialized let binding is an error, then hoisting is pointless except to make the statements between start of block and the let declaration a dead zone for the binding name. This fits the ancient, weak

Re: return when desugaring to closures

2008-10-13 Thread Jon Zeppieri
On Mon, Oct 13, 2008 at 6:34 PM, Brendan Eich [EMAIL PROTECTED] wrote: On the contrary, what's magical is when one stores i in elements of an array, or calls setTimeout (example in https://bugzilla.mozilla.org/show_bug.cgi?id=449811) , and the results are all the last value of the loop

Re: return when desugaring to closures

2008-10-13 Thread Waldemar Horwat
Brendan Eich wrote: On Oct 13, 2008, at 3:56 PM, Waldemar Horwat wrote: Brendan Eich wrote: The agreement from the May TC39 meeting was that the declarations implicit (:*) and explicit annotations must normalize to the same type, or there's an error. That was back when the language had

Re: return when desugaring to closures

2008-10-13 Thread Brendan Eich
On Oct 13, 2008, at 4:14 PM, Jon Zeppieri wrote: Yes, and binding a fresh induction variable on every iteration makes sense for a 'for-each' loop (as in the bug report you cited), where the user is not in charge of updating the induction variable by means of explicit assignment. In a plain

Re: return when desugaring to closures

2008-10-13 Thread David-Sarah Hopwood
David-Sarah Hopwood wrote: Mark S. Miller wrote: [...] I recommend the per-iteration view. If we can agree quickly on per-iteration, then for (const x = ...) {...x...} should be allowed in ES3.1 (whether or not const hoists to block start). After ES3.1 for (const i :T[i] = ...)

Re: return when desugaring to closures

2008-10-13 Thread Waldemar Horwat
Mark S. Miller wrote: On Sat, Oct 11, 2008 at 9:11 AM, Peter Michaux [EMAIL PROTECTED] wrote: I think it would be ok to have only unnamed lambdas. (It would be ok to have named lambdas too.) I think we should not introduce named lambdas because then we'd need to decide whether the scoping

Re: return when desugaring to closures

2008-10-13 Thread Jon Zeppieri
On Mon, Oct 13, 2008 at 7:39 PM, Brendan Eich [EMAIL PROTECTED] wrote: On Oct 13, 2008, at 4:14 PM, Jon Zeppieri wrote: Yes, and binding a fresh induction variable on every iteration makes sense for a 'for-each' loop (as in the bug report you cited), where the user is not in charge of

Re: return when desugaring to closures

2008-10-13 Thread Brendan Eich
On Oct 13, 2008, at 4:09 PM, Brendan Eich wrote: On Oct 13, 2008, at 4:01 PM, Waldemar Horwat wrote: Brendan Eich wrote: If using an uninitialized let binding is an error, then hoisting is pointless except to make the statements between start of block and the let declaration a dead zone

Re: return when desugaring to closures

2008-10-13 Thread Waldemar Horwat
Brendan Eich wrote: On Oct 13, 2008, at 4:01 PM, Waldemar Horwat wrote: Brendan Eich wrote: If using an uninitialized let binding is an error, then hoisting is pointless except to make the statements between start of block and the let declaration a dead zone for the binding name. This fits

Re: return when desugaring to closures

2008-10-13 Thread Brendan Eich
On Oct 13, 2008, at 5:00 PM, Jon Zeppieri wrote: On Mon, Oct 13, 2008 at 7:39 PM, Brendan Eich [EMAIL PROTECTED] wrote: On Oct 13, 2008, at 4:14 PM, Jon Zeppieri wrote: Yes, and binding a fresh induction variable on every iteration makes sense for a 'for-each' loop (as in the bug report

Re: return when desugaring to closures

2008-10-13 Thread Waldemar Horwat
David Herman wrote: Also, I wonder why lambda in it's block-less form is restricted to expressions. I'm with you... but I'd want to check with the experts on the ES grammar to see whether this introduces any nasty ambiguities. Please specify what you are proposing. The one proposal I've

Re: return when desugaring to closures

2008-10-13 Thread Brendan Eich
On Oct 13, 2008, at 4:54 PM, Waldemar Horwat wrote: I am talking about let bindings. Lars brought up at that meeting. I did not find the use cases particularly convincing, but the dead zone is compelling. There are four ways to do this: A1. Lexical dead zone. References textually

Re: return when desugaring to closures

2008-10-13 Thread Waldemar Horwat
Brendan Eich wrote: On Oct 13, 2008, at 5:29 PM, Waldemar Horwat wrote: Brendan Eich wrote: On Oct 13, 2008, at 3:51 PM, Waldemar Horwat wrote: Brendan Eich wrote: After some experiments, we decided for ES4 to make let and var the same at top level in a function or global code. ... You

Re: return when desugaring to closures

2008-10-13 Thread Brendan Eich
On Oct 13, 2008, at 6:08 PM, Waldemar Horwat wrote: Brendan Eich wrote: Because presumably the let x:t became var x:t and var can't have types? Why can't var have a type annotation? Because a function can have many var declarations for the same variable and because you can use the

Re: return when desugaring to closures

2008-10-13 Thread David-Sarah Hopwood
Waldemar Horwat wrote: I am talking about let bindings. Lars brought up at that meeting. I did not find the use cases particularly convincing, but the dead zone is compelling. There are four ways to do this: A1. Lexical dead zone. References textually prior to a definition in the same

Re: return when desugaring to closures

2008-10-13 Thread David-Sarah Hopwood
David-Sarah Hopwood wrote: Waldemar Horwat wrote: I am talking about let bindings. Lars brought up at that meeting. I did not find the use cases particularly convincing, but the dead zone is compelling. There are four ways to do this: A1. Lexical dead zone. References textually prior to

Re: return when desugaring to closures

2008-10-12 Thread David-Sarah Hopwood
Yuh-Ruey Chen wrote: Mark S. Miller wrote: On Sat, Oct 11, 2008 at 4:33 PM, Dave Herman [EMAIL PROTECTED] wrote: Expression ::= ... | lambda Formals? Statement Statement or SubStatement? If Statement, what meaning do you propose for { const f = (lambda () const x = 3;); x

Re: return when desugaring to closures

2008-10-12 Thread Yuh-Ruey Chen
David-Sarah Hopwood wrote: Yuh-Ruey Chen wrote: Now that I think about it, would it truly be necessary for lambda to create an implicit block scope in the first place? It's not strictly necessary, but it's quite ugly not to. We are intending to restrict 'eval' precisely to remove the

Re: return when desugaring to closures

2008-10-12 Thread Mark S. Miller
On Sun, Oct 12, 2008 at 2:19 PM, Yuh-Ruey Chen [EMAIL PROTECTED] wrote: David-Sarah Hopwood wrote: { while (...) let x = ...; } I was under the impression that such statements should be disallowed, following the example of JS1.8. In JS1.8 (Fx3), the following are all syntax errors: while

Re: return when desugaring to closures

2008-10-12 Thread David-Sarah Hopwood
Mark S. Miller wrote: On Sun, Oct 12, 2008 at 2:19 PM, Yuh-Ruey Chen [EMAIL PROTECTED] wrote: David-Sarah Hopwood wrote: { while (...) let x = ...; } I was under the impression that such statements should be disallowed, following the example of JS1.8. In JS1.8 (Fx3), the following are all

Re: return when desugaring to closures

2008-10-12 Thread David-Sarah Hopwood
Mark S. Miller wrote: On Sun, Oct 12, 2008 at 2:19 PM, Yuh-Ruey Chen [EMAIL PROTECTED] wrote: David-Sarah Hopwood wrote: { while (...) let x = ...; } I was under the impression that such statements should be disallowed, following the example of JS1.8. In JS1.8 (Fx3), the following are all

Re: return when desugaring to closures

2008-10-12 Thread YR Chen
On Sun, Oct 12, 2008 at 7:34 PM, David-Sarah Hopwood [EMAIL PROTECTED] wrote: So why are we arguing about whether lambdas should be allowed without braces, when the direction being taken for the rest of the language is to make the braces mandatory around all forms that can potentially

Re: return when desugaring to closures

2008-10-12 Thread Mark S. Miller
On Sun, Oct 12, 2008 at 5:45 PM, David-Sarah Hopwood [EMAIL PROTECTED] wrote: Since LabelledStatement is included in SubStatement, the following is allowed in the current ES3.1 draft: while (...) foo: var x = ...; This will be corrected in the next version. But the agreed fix is not to make

Re: return when desugaring to closures

2008-10-12 Thread David-Sarah Hopwood
YR Chen wrote: On Sun, Oct 12, 2008 at 7:34 PM, David-Sarah Hopwood [EMAIL PROTECTED] wrote: So why are we arguing about whether lambdas should be allowed without braces, when the direction being taken for the rest of the language is to make the braces mandatory around all forms that can

Re: return when desugaring to closures

2008-10-12 Thread Mark S. Miller
On Sun, Oct 12, 2008 at 7:55 PM, David-Sarah Hopwood [EMAIL PROTECTED] wrote: In ES3.1, this will mean that they normally require braces whenever a body can introduce variables. There are two classes of exceptions, shown by these examples: a) while (...) foo: var x = ...; b) while (...)

Re: return when desugaring to closures

2008-10-11 Thread David Herman
if (h == 0) h = function() {break}; Did you mean if (x == 0)? That's been confusing me in trying to read your example. Dave ___ Es-discuss mailing list Es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: return when desugaring to closures

2008-10-11 Thread Peter Michaux
On Sat, Oct 11, 2008 at 10:02 AM, Mark S. Miller [EMAIL PROTECTED] wrote: On Sat, Oct 11, 2008 at 9:11 AM, Peter Michaux [EMAIL PROTECTED] wrote: As it stands, I always write the following in ES3 var f = function() {}; and now that arguments.callee is on the chopping block, I've started

Re: return when desugaring to closures

2008-10-11 Thread David-Sarah Hopwood
Peter Michaux wrote: On Sat, Oct 11, 2008 at 10:02 AM, Mark S. Miller [EMAIL PROTECTED] wrote: On Sat, Oct 11, 2008 at 9:11 AM, Peter Michaux [EMAIL PROTECTED] wrote: As it stands, I always write the following in ES3 var f = function() {}; and now that arguments.callee is on the chopping

Re: return when desugaring to closures

2008-10-11 Thread Peter Michaux
On Sat, Oct 11, 2008 at 11:59 AM, Brendan Eich [EMAIL PROTECTED] wrote: On Oct 11, 2008, at 9:05 AM, Peter Michaux wrote: How to define a variable that is local to the enclosing lambda? Isn't the ability to do that essential? Use let (the var replacement declaration form). Sounds good to me

Re: return when desugaring to closures

2008-10-11 Thread David Herman
Also, I wonder why lambda in it's block-less form is restricted to expressions. I'm with you... but I'd want to check with the experts on the ES grammar to see whether this introduces any nasty ambiguities. Dave ___ Es-discuss mailing list

Re: return when desugaring to closures

2008-10-11 Thread David Herman
Sounds good to me but it is a little confusing to keep track if let is either in or out of ES-Harmony and if it is partly in then which of the several JavaScript 1.7 uses are in and if there will be let, let*, letrec semantics. I've got no crystal ball, but I'd say it'd be unlikely (and

Re: return when desugaring to closures

2008-10-11 Thread Mark S. Miller
On Sat, Oct 11, 2008 at 12:52 PM, Peter Michaux [EMAIL PROTECTED] wrote: Use let (the var replacement declaration form). Sounds good to me but it is a little confusing to keep track if let is either in or out of ES-Harmony and if it is partly in then which of the several JavaScript 1.7 uses

Re: return when desugaring to closures

2008-10-11 Thread Peter Michaux
On Sat, Oct 11, 2008 at 1:21 PM, Mark S. Miller [EMAIL PROTECTED] wrote: The let declaration is in. Like const and function declarations, it has block-level letrec lexical scoping. I continue to oppose let expressions and let statements, as they don't provide enough additional power to

Re: return when desugaring to closures

2008-10-11 Thread Brendan Eich
On Oct 11, 2008, at 12:55 PM, David Herman wrote: How to define a variable that is local to the enclosing lambda? Isn't the ability to do that essential? No. With all due respect to Brendan, `var' hoisting to the top of a function body is one of the more problematic aspects of ES's

Re: return when desugaring to closures

2008-10-11 Thread Brendan Eich
On Oct 11, 2008, at 12:52 PM, Peter Michaux wrote: On Sat, Oct 11, 2008 at 11:59 AM, Brendan Eich [EMAIL PROTECTED] wrote: On Oct 11, 2008, at 9:05 AM, Peter Michaux wrote: How to define a variable that is local to the enclosing lambda? Isn't the ability to do that essential? Use let

Re: return when desugaring to closures

2008-10-11 Thread Brendan Eich
On Oct 11, 2008, at 2:43 PM, Brendan Eich wrote: On Oct 11, 2008, at 12:52 PM, Peter Michaux wrote: and if it is partly in then which of the several JavaScript 1.7 uses are in and if there will be let, let*, letrec semantics. It's something else. See my reply about hoisting, just sent.

Re: return when desugaring to closures

2008-10-11 Thread Mark S. Miller
Hi Dave, first, my compliments on your lambda proposal. This should significantly simplify the core language after expanding sugars -- especially if you succeed at redefining function as desugaring to lambdas. That would be awesome! On Sat, Oct 11, 2008 at 5:34 AM, David Herman [EMAIL PROTECTED]

Re: return when desugaring to closures

2008-10-11 Thread Brendan Eich
On Oct 11, 2008, at 2:55 PM, Mark S. Miller wrote: On Sat, Oct 11, 2008 at 2:42 PM, Brendan Eich [EMAIL PROTECTED] wrote: We've discussed making use-before-set a strict error, but we've avoided it. The initialiser is not mandatory, and we do not wish to impose costly analysis on small

Re: return when desugaring to closures

2008-10-11 Thread Mark S. Miller
On Sat, Oct 11, 2008 at 3:26 PM, Brendan Eich [EMAIL PROTECTED] wrote: Of course, let expressions would need lambda-coding no matter what names were shadowed. The experience gained in JS1.7+ shows more let block usage than let expression, but expression temporaries (lacking macros and ignoring

Re: return when desugaring to closures

2008-10-11 Thread Mark S. Miller
On Sat, Oct 11, 2008 at 4:05 PM, Dave Herman [EMAIL PROTECTED] wrote: Read the proposal again: the statement form of lambdas *does* return the value of its last expression; this is what ES3 calls the completion value. Cool! So why are we still discussing proposed let expressions and let blocks

Re: return when desugaring to closures

2008-10-10 Thread Brendan Eich
On Oct 9, 2008, at 8:57 PM, Peter Michaux wrote: This keyword/scoping problem must already have appeared for functions as function declarations have var scoping and obtaining let scoping requires using something like let a = function(){}. This is pretty ugly for functions to have let scoping

Re: return when desugaring to closures

2008-10-10 Thread David-Sarah Hopwood
Peter Michaux wrote: This keyword/scoping problem must already have appeared for functions as function declarations have var scoping and obtaining let scoping requires using something like let a = function(){}. This is pretty ugly for functions to have let scoping but the good news is the

Re: return when desugaring to closures

2008-10-10 Thread Brendan Eich
On Oct 10, 2008, at 1:25 PM, Waldemar Horwat wrote: So what should f(5, 0) do? function f(x, h) { while (true) { try { if (h == 0) h = function() {break}; Just to repeat something Dave wrote, we don't propose to allow break in a function where the break is not in a

Re: return when desugaring to closures

2008-10-10 Thread Brendan Eich
On Oct 10, 2008, at 3:31 PM, Brendan Eich wrote: } catch (e) { alert(caught + e + on + x); } finally { alert(f called finally on + x); } Skipping the intervening active finally clauses is bad, though -- a bug in the current wiki rough draft that I should have mentioned.

Re: return when desugaring to closures

2008-10-10 Thread Yuh-Ruey Chen
David Herman wrote: My question was whether the semantics of break and continue would support the following: Yes, this is another good case to consider. Thanks for pointing it out; I'll add this to the strawman:lambdas proposal. Essentially this is another aspect of the semantics of

Re: return when desugaring to closures

2008-10-09 Thread Brendan Eich
On Sep 2, 2008, at 2:16 PM, Lex Spoon wrote: On Sun, Aug 24, 2008 at 3:17 AM, Brendan Eich [EMAIL PROTECTED] wrote: First, let's settle the hash over whether any desugaring without extensions such as return-to-label, reformed lexical scope, tamed this, banished arguments, etc. etc., trumps

Re: return when desugaring to closures

2008-10-09 Thread Lex Spoon
On Thu, Oct 9, 2008 at 5:31 PM, Brendan Eich [EMAIL PROTECTED] wrote: JS has break from labeled statement, and continue to labeled loop bottom, a la Java. These look trouble-free to me. Let me know if you see a hard case. Thanks, My question was whether the semantics of break and continue

Re: return when desugaring to closures

2008-10-09 Thread Brendan Eich
On Oct 9, 2008, at 3:05 PM, Lex Spoon wrote: On Thu, Oct 9, 2008 at 5:31 PM, Brendan Eich [EMAIL PROTECTED] wrote: JS has break from labeled statement, and continue to labeled loop bottom, a la Java. These look trouble-free to me. Let me know if you see a hard case. Thanks, My

Re: return when desugaring to closures

2008-10-09 Thread Brendan Eich
On Oct 9, 2008, at 4:28 PM, David Herman wrote: How would people feel about the declaration form being 'define' instead of lambda? As in: define const(x) { lambda(y) x } Maybe I'm just accustomed to Scheme, but it looks awkward to me for the declaration form to be called

Re: return when desugaring to closures

2008-10-09 Thread David Herman
@mozilla.org Sent: Thursday, October 9, 2008 9:12:26 PM GMT -05:00 US/Canada Eastern Subject: Re: return when desugaring to closures On Oct 9, 2008, at 4:28 PM, David Herman wrote: How would people feel about the declaration form being 'define' instead of lambda? As in: define const(x

  1   2   >