-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
let for #164
Comments
|
Yes, |
Any +1/-1 ? I think it's a regular use case (please |
FWIW, ES6 version will look like: |
I doesn't matter much, both syntaxes are ok. True with the parenthesis it looks as nice, without a bit less - but I'd still be as happy. |
More analysisWe already got idioms using
|
This does not work : for [x,y,z] of b
let
x + y + z For let would capture any loop variable, even the destructurations |
Nope, because auto-binding all of them is costly and may not be desirable (and you can always do
Both, I suppose. |
That's what the suggestion is for. Capture them. Maybe you can consider searching them in the block, like that/if. May be costly too, but not at runtime. |
Naturally it will, since it won't have to expose the bindings to the outer scope as well.
will compile roughly as:
|
Which is what we're looking for, isn't it ? |
Okay, I have something. It got over my head really fast, I guess I need far more experience haha |
My diff is here. (still a $ node lib/command -bce "let for a in b then"
var a;
for (a in b) {
(fn$.call(this, a))
}
function fn$(a){}
|
|
Cleanest way I think of, to avoid messing with LoopHeads, would be to invert tokens in the lexer. Or is there anything else ?
When is that ? In
Will fix. Thanks |
Yep, you'd need to hack lexer.
In this case you need to break it. It should return the whole |
Ok, so just before calling compileBody, else there's no access to
Right. So I need to I see a bit better how that goes. Will hack on it after lunch :).Thanks again. |
Ok, I think this is more correct : 7915ca5...1701fae
just inverting |
@satyr are you okay with that ? Do you want me to add/change something, rule-wise or syntax-wise ? |
Yes. Should support
Doesn't work quite right in nested cases. Try e.g.:
Similarly, any |
Done. Disallowed
Not sure how to with for let a in b
continue will get optimized away and for let a in b
1
continue No idea how to properly exclude if @body.getJump!
that instanceof Return or that.carp 'inconvertible statement' For eq '1', ''+for let a in [0]
return 1 I get an error because of (or thanks to, again) Node::compileClosure. I don't mind adding a
Fails due to my previous point |
I guess I give up tutoring this time. Will get my hands dirty. |
Thanks for both! |
jashkenas/coffeescript#2518
let for
looks right to me, orfor let
The text was updated successfully, but these errors were encountered: