Skip to content

Instantly share code, notes, and snippets.

@mossprescott
Created July 2, 2014 18:04
Show Gist options
  • Select an option

  • Save mossprescott/7d96067b651c67d7c3b2 to your computer and use it in GitHub Desktop.

Select an option

Save mossprescott/7d96067b651c67d7c3b2 to your computer and use it in GitHub Desktop.
Two styles for closing parens
// 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))))
@jdegoes

jdegoes commented Jul 2, 2014

Copy link
Copy Markdown

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?

@sellout

sellout commented Jul 2, 2014

Copy link
Copy Markdown

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.

@jdegoes

jdegoes commented Jul 2, 2014

Copy link
Copy Markdown

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.

@mossprescott

Copy link
Copy Markdown
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