Created
July 2, 2014 18:04
-
-
Save mossprescott/7d96067b651c67d7c3b2 to your computer and use it in GitHub Desktop.
Two styles for closing parens
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // With dangling parens: | |
| Let('tmp0, | |
| read("cities"), | |
| Let('tmp1, | |
| makeObj( | |
| "0" -> | |
| Add( | |
| Divide( | |
| Multiply( | |
| ObjectProject(Free('tmp0), Constant(Data.Str("avgTemp"))), | |
| Constant(Data.Int(9)) | |
| ), | |
| Constant(Data.Int(5)) | |
| ), | |
| Constant(Data.Int(32)) | |
| ) | |
| ), | |
| free('tmp1) | |
| ) | |
| ) | |
| // With "rolled-up" parens: | |
| Let('tmp0, read("cities"), | |
| Let('tmp1, | |
| makeObj( | |
| "0" -> | |
| Add( | |
| Divide( | |
| Multiply( | |
| ObjectProject(free('tmp0), constant(Data.Str("avgTemp"))), | |
| Constant(Data.Int(9))), | |
| Constant(Data.Int(5))), | |
| Constant(Data.Int(32)))), | |
| Free('tmp1)))) |
Official style guide says “rolled-up”, with non-specific exceptions: http://docs.scala-lang.org/style/nested-blocks.html
I have Strong Opinions on this, but I think it’d be better to discuss in the office, rather than a bunch of comments back and forth here.
You do know we settle all differences of opinion on style by arm wrestling contests, right? :)
Yeah, works for me, let's talk style when you get back.
Author
I'm still not committed either way. Mostly I'm offended that I even have to write the damn parens. But I don't like the sound of this arm-wrestling business at all...
I do think this sort of thing is good to work out early, based on previous experience.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I guess I prefer dangling parens, mainly because Scala is a curly-brace language, so it's common to align the beginning of something with the end of that thing. Also in various places you can use either parens or braces, and the braces have a very strong convention of being aligned, so it would be odd to switch formatting just because you changed which one you were using.
Thoughts?