Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

But that doubly defeats the purpose.

1. If you have good reasons to restrict variable access in subsections of your long procedure, then it DOES make sense to factor them out as separate functions.

2. Closures automatically close over variables from the surrounding scope (duh), so they don't protect you from accidentally using a variable in a section that you're not supposed to use it in.



The lambda approach avoids "I can't think of what I should call this, I'll call it `foo` for now" problem...

Which isn't a problem we should be avoiding. Naming things in a way that other coders will understand is an important skill, and can be difficult.


How does it avoid that problem?

The lambda doesn't help me understand what that part actually does any more than calling the function "foo_helper" or "foo_partN" or something like that would do.


> Which isn't a problem we should be avoiding

I believe we're actually arguing the same thing.

Anonymous functions aren't the end of the world, but self-documenting code is better.

In the JS/JQuery world, breaking away from anonymous functions would represent such a fundamental shift in practice, I'm not going to do it on my own, but in Angular, I stay away from anonymous functions.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: