Skip to content

Simplify do.coffee #3577

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

Closed
wants to merge 2 commits into from
Closed

Simplify do.coffee #3577

wants to merge 2 commits into from

Conversation

bfab
Copy link

@bfab bfab commented Aug 8, 2014

This version is directly executable, and illustrates more directly the concept. One can comment out line #3 and run again to see the difference.

This version is directly executable, and illustrates more directly the concept. One can comment out line jashkenas#3 and run again to see the difference.
multipliers = [1, 2, 3]
multiples = for j in multipliers
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't these names backwards? Functions should have verb names and non-functions values should have noun names.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mathematically speaking, a multiple where the multiplier is specified and the quantity to multiply it with is not, is a lambda function, isn't it?

@bfab
Copy link
Author

bfab commented Aug 9, 2014

I just noticed the same code appears in index.html.
Is that code duplication (meaning that this pull request should change both places)?

@vendethiel
Copy link
Collaborator

No, it's just compiled.

...as "multiplier" indicates "what multiplies", which refers to an action and as such may be confusing (as those are not functions), though in mathematical terms "multiplier" and "coefficient" are synonyms.
Can't think of a better alternative for "multiple", which seems mathematically sound and makes this example still better than the original (imho).
@GeoffreyBooth
Copy link
Collaborator

I think the current example is actually more appropriate. A variable name like err is exactly the type of variable you want to wrap a closure around, to limit in scope. Also this example uses a for loop as the right hand of an assignment, which is an unusual pattern that could confuse people.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants