- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Scala code style document
Thu, 2009-02-12, 21:42
Hello, all.
From some people I heard about mythical document with Scala code conventions.
If it really exists we would like to make such formatting options default fo IntelliJ plugin. So, could someone provide it?
Thanks.
Kind regards,
Ilya
From some people I heard about mythical document with Scala code conventions.
If it really exists we would like to make such formatting options default fo IntelliJ plugin. So, could someone provide it?
Thanks.
Kind regards,
Ilya
Thu, 2009-02-12, 22:27
#2
Re: Scala code style document
Hi, David.
I meant this post by David Pollak (to be precise, its last part with suggestions :).
http://blog.lostlake.org/index.php?/archives/91-IntelliJ-update-its-still-a-piece-of-junk-but-Scala-support-isnt-bad.html
That's exactly what we have by default.
Thanks.
Kind regards,
Ilya
2009/2/12 David MacIver <david.maciver@gmail.com>
Gee, I wonder who. :-)
I meant this post by David Pollak (to be precise, its last part with suggestions :).
http://blog.lostlake.org/index.php?/archives/91-IntelliJ-update-its-still-a-piece-of-junk-but-Scala-support-isnt-bad.html
- tabs, not spaces
- two space indents
- open braces don't start a new line
- type annotations are spaced as foo: Bar
That's exactly what we have by default.
Thanks.
Kind regards,
Ilya
2009/2/12 David MacIver <david.maciver@gmail.com>
On Thu, Feb 12, 2009 at 8:42 PM, Ilya Sergey <ilya.sergey@jetbrains.com> wrote:
Hello, all.
From some people I heard about mythical document with Scala code conventions.
Gee, I wonder who. :-)
If it really exists we would like to make such formatting options default fo IntelliJ plugin. So, could someone provide it?
Thanks.
Kind regards,
Ilya
I think it's called "the compiler source code" I'm afraid. At least that's what I seem to recall being told when I started committing.
The big things I'm aware of are:
- tabs, not spaces
- two space indents
- open braces don't start a new line
- /* */ comments are only used for scaladoc method comments, line comments are used elsewhere (the cynical might note that "comments are not used elsewhere" could also reasonably be inferred from parts of the compiler source code)
- type annotations are spaced as foo: Bar
Not sure what else.
Thu, 2009-02-12, 22:37
#3
Re: Scala code style document
On Thu, Feb 12, 2009 at 9:18 PM, Ilya Sergey <ilya.sergey@jetbrains.com> wrote:
Yes, I'd assumed that.
Don't know what David was thinking of then! You'll have to ask him.
Oh, for what it's worth, one thing I've noticed is that people tend not to use semicolons. This is pretty inconsistently applied though.
Hi, David.Gee, I wonder who. :-)
I meant this post by David Pollak (to be precise, its last part with suggestions :).
http://blog.lostlake.org/index.php?/archives/91-IntelliJ-update-its-still-a-piece-of-junk-but-Scala-support-isnt-bad.html
Yes, I'd assumed that.
- tabs, not spaces
- two space indents
- open braces don't start a new line
- type annotations are spaced as foo: Bar
That's exactly what we have by default.
Don't know what David was thinking of then! You'll have to ask him.
Oh, for what it's worth, one thing I've noticed is that people tend not to use semicolons. This is pretty inconsistently applied though.
Thu, 2009-02-12, 22:47
#4
Re: Scala code style document
On Thu, Feb 12, 2009 at 1:22 PM, David MacIver <david.maciver@gmail.com> wrote:
On Thu, Feb 12, 2009 at 9:18 PM, Ilya Sergey <ilya.sergey@jetbrains.com> wrote:Hi, David.Gee, I wonder who. :-)
I meant this post by David Pollak (to be precise, its last part with suggestions :).
http://blog.lostlake.org/index.php?/archives/91-IntelliJ-update-its-still-a-piece-of-junk-but-Scala-support-isnt-bad.html
Yes, I'd assumed that.
- tabs, not spaces
- two space indents
- open braces don't start a new line
- type annotations are spaced as foo: Bar
That's exactly what we have by default.
Don't know what David was thinking of then! You'll have to ask him.
Oh, for what it's worth, one thing I've noticed is that people tend not to use semicolons. This is pretty inconsistently applied though.
Apparently Julien Wetterwald wrote one when he was at EPFL. When he joined the Lift project, he advocated use of the document. He wrote a post about it here: http://groups.google.com/group/liftweb/msg/b02f9cd72e9fe78a?hl=en
I've pinged Julien and introduced him to Ilya, but Julie hasn't followed up.
Thanks,
David
--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Git some: http://github.com/dpp
Thu, 2009-02-12, 22:57
#5
Re: Scala code style document
On Thu, Feb 12, 2009 at 9:35 PM, David Pollak <feeder.of.the.bears@gmail.com> wrote:
I'm not sure this can really be regarded as canonical. Particularly given that this is the first time I've seen anything resembling it. :-) Additionally, it doesn't seem to be followed at all closely in the compiler or standard library sources.
1. A brief inspection suggests that this is not the way matches are aligned in the compiler. The convention seems to be
def foo(stuff : Stuff) = stuff match {
case Thing => ...
}
So the indentation is as described but the line breaking is not.
2. This definitely isn't adhered to. New lines and same line cases are mixed all over the place. (I'm fine with that. It looks totally reasonable to me.)
3. Couldn't say off the top of my head. It's not IDE relevant anyway.
4. No. The standard convention I've seen most people use (including the library and compiler sources) is that toStuff and isThing are used but setName and getName are not. Not really IDE relevant unless the refactoring support in IDEA is much further along than I thought.
Other 4. Sure. This seems good practice. I'm not sure if the compiler actually uses it, but it's common enough. Again not IDE relevant.
5. Whether or not it's standard (I'm not sure it is. It's certainly *used*, but I don't know that it's used at all consistently), this is a pretty controversial one. Also not IDE relevant.
Don't know what David was thinking of then! You'll have to ask him.
Oh, for what it's worth, one thing I've noticed is that people tend not to use semicolons. This is pretty inconsistently applied though.
Apparently Julien Wetterwald wrote one when he was at EPFL. When he joined the Lift project, he advocated use of the document. He wrote a post about it here: http://groups.google.com/group/liftweb/msg/b02f9cd72e9fe78a?hl=en
I'm not sure this can really be regarded as canonical. Particularly given that this is the first time I've seen anything resembling it. :-) Additionally, it doesn't seem to be followed at all closely in the compiler or standard library sources.
1. A brief inspection suggests that this is not the way matches are aligned in the compiler. The convention seems to be
def foo(stuff : Stuff) = stuff match {
case Thing => ...
}
So the indentation is as described but the line breaking is not.
2. This definitely isn't adhered to. New lines and same line cases are mixed all over the place. (I'm fine with that. It looks totally reasonable to me.)
3. Couldn't say off the top of my head. It's not IDE relevant anyway.
4. No. The standard convention I've seen most people use (including the library and compiler sources) is that toStuff and isThing are used but setName and getName are not. Not really IDE relevant unless the refactoring support in IDEA is much further along than I thought.
Other 4. Sure. This seems good practice. I'm not sure if the compiler actually uses it, but it's common enough. Again not IDE relevant.
5. Whether or not it's standard (I'm not sure it is. It's certainly *used*, but I don't know that it's used at all consistently), this is a pretty controversial one. Also not IDE relevant.
Fri, 2009-02-13, 09:37
#6
Re: Scala code style document
On Feb 12, 2009, at 10:11 PM, David MacIver wrote:
> The big things I'm aware of are:
>
> - tabs, not spaces
I always thought it's the other way around! :)
iulian
>
> - two space indents
>
> - open braces don't start a new line
> - /* */ comments are only used for scaladoc method comments, line
> comments are used elsewhere (the cynical might note that "comments
> are not used elsewhere" could also reasonably be inferred from parts
> of the compiler source code)
> - type annotations are spaced as foo: Bar
>
>
> Not sure what else.
--
Iulian Dragos
--
http://lamp.epfl.ch/~dragos
Fri, 2009-02-13, 11:47
#7
Re: Scala code style document
On Fri, Feb 13, 2009 at 8:24 AM, Iulian Dragos <iulian.dragos@epfl.ch> wrote:
Oops.
Yes. I very much meant the other way round. Sorry for any confusion.
On Feb 12, 2009, at 10:11 PM, David MacIver wrote:
The big things I'm aware of are:
- tabs, not spaces
I always thought it's the other way around! :)
Oops.
Yes. I very much meant the other way round. Sorry for any confusion.
Gee, I wonder who. :-)
I think it's called "the compiler source code" I'm afraid. At least that's what I seem to recall being told when I started committing.
The big things I'm aware of are:
- tabs, not spaces
- two space indents
- open braces don't start a new line
- /* */ comments are only used for scaladoc method comments, line comments are used elsewhere (the cynical might note that "comments are not used elsewhere" could also reasonably be inferred from parts of the compiler source code)
- type annotations are spaced as foo: Bar
Not sure what else.