Skip to content
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

Usage of underscore #59

Open
frgomes opened this issue Nov 14, 2018 · 0 comments
Open

Usage of underscore #59

frgomes opened this issue Nov 14, 2018 · 0 comments

Comments

@frgomes
Copy link

frgomes commented Nov 14, 2018

I would like to see some convergence about best practices involving underscore.
IMHO underscore should be read by humans as "I don't care", "it does not care", "it does not matter", "ignored" or "irrelevant".

So, if you find a snippet of code like this:

  val parseFile: Transformer[File, Reading] = _.concatMap { file => ... }

... you should read as "it does not care".concatMap or "ignored".contactMap or "irrelevant".concatMap, right? Well... this is obvious that the underscore in this case is key for understanding what the code does, which means that I should care about the underscore, it cannot be ignored and it is definitely relevant.

The compiler may be plenty able to identify what the underscore is about (in microseconds!). However, humans may take several minutes to understand what this code is about.

Humans should write code primarily for other humans understand.

A best practice would be writing clean code (no magic!) targetting a human audience.

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

No branches or pull requests

1 participant