-
Notifications
You must be signed in to change notification settings - Fork 2k
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
put utility functions at the bottom of the script #1638
Comments
+1 |
+1 (it would be pretty cool to actually have Google+ buttons here) |
related: satyr/coco@63d66d7 |
I'm conflicted about this one. I agree that, as compiler output, it's great to leave the boilerplate out of the way as much as possible. That said, there's a reason that CoffeeScript doesn't allow function declarations -- it's truly bizarre to use a lexically-scoped function before it's even declared or defined. When reading a compiled JS file, you'd be seeing Is it worth giving up one sense of readability in favor of the other? |
@jashkenas: (in my opinion) Yes. Once you read a single coffeescript output, you'll know about these. You don't need them getting in your way on subsequent inspections. |
The fact that these names begin with |
👍 (+1) |
related: 0199515 and the commit comments |
+1 Though this becomes unnecessary when the debugging improves to show the actual line of an error. |
@jussiry: this has nothing to do with line mapping and everything to do with readability. |
out of interest : is there any work on making this happen ? On Thu, Sep 29, 2011 at 9:15 PM, jussiry <
|
@weepy: see my comment above with the link to the commit comments from 0199515. This could easily be done in 20 minutes by someone willing to put in the time. Like you. Even an inexperienced dev. would probably be able to fix it in under an hour. I'd love to -- I think it would be rather fun -- but I almost always have much higher priority tasks than having fun. |
I'm afraid that wrapping all uses of |
@jashkenas: it's only the first use, not every one. Take a closer look. |
Cute. Isn't that sort of name re-use exactly the thing that old IE's will choke on? |
Nope, I believe that occurs when assigning named function expressions to variables of the same name. Since we're not naming our function expressions, we should be fine. Though someone please correct me if I'm wrong; I have no way to test on IE. |
michaelficarra : I can't see how the commit really relates to my comment which was asking about whether it was possible to report on the actual source error line number? Obviously it makes the line numbers less wrong, but the problem still exists ? |
As of #4526 we have only one-liner helper functions, so the readability issue is less urgent. This doesn’t appear to be a priority, so I’m closing the issue. If someone wants to submit a PR that improves things, it would be welcome. |
At the moment, CoffeeScript puts the utility functions at the top of the script (as it does with all other variables). Unfortunately This causes the preamble of the file to be quite long - and it pushes line numbers further out.
If named functions were used instead, the functions could be placed at the bottom of the file as they would still be in scope.
Here's an example as a gist : https://gist.github.com/1180503
The text was updated successfully, but these errors were encountered: