Skip to content

Scala Code Style multiple import statement #237

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

Open
Marza opened this issue Aug 27, 2013 · 4 comments
Open

Scala Code Style multiple import statement #237

Marza opened this issue Aug 27, 2013 · 4 comments

Comments

@Marza
Copy link

Marza commented Aug 27, 2013

What is the preferred style of multiple import statements? I didn't find any documentation about this in the style guide.

The Scala cheatsheet has this example:

import scala.collection.{Vector, Sequence}

Which also seems to be the format IntelliJ prefers but scalariform enforces the following formatting:

import scala.collection.{ Vector, Sequence }

I personally prefer the first one.

@Marza
Copy link
Author

Marza commented Aug 27, 2013

No spacing inside curlies seems to be the rule in Twitter's scala guide at http://twitter.github.io/effectivescala/

Use braces when importing several names from a package
import com.twitter.concurrent.{Broker, Offer}

Took a look in the scala-lang source code where spaces were added inside curlies, anyone know why?

@heathermiller
Copy link
Member

Yep, you're right that there's an ambiguity here. I don't know if there's really a best practice here, personally I abide by Twitter's standard – no spaces in imports. But I'm not sure if that's what most people would agree with.

I know that it's kind of a small detail, but might be worth bringing up on scala-debate or scala-language to get a final verdict? I'd be happy to pull in anything agreed upon :)

@Marza
Copy link
Author

Marza commented Aug 27, 2013

I started a topic in scala-debate https://groups.google.com/forum/#!topic/scala-debate/v9XAsYE4TfI lets see if we can bring in some opinions.

@SethTisue
Copy link
Member

I don't think there is a consensus on this. I wouldn't be against having the style guide say both are acceptable.

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

No branches or pull requests

3 participants