|
Brace style bias?: msg#00413lang.scala
I've just been bitten by an interaction between Scala's newline rules and my prefered brace style (BSD/Allman style[1], As God Intended ;-). I was trying to write the following, class DisjointUnion[A](family : List[Set[A]]) extends Set[A] { val size = ... def contains(elem: A) = ... def elements = new Iterator[A] // <-- error here { ... } } which failed with the compiler error "trait Iterator is abstract; cannot be instantiated". On switching to K&R style, def elements = new Iterator[A] { ... } everything is hunky dory. Looking at criteria (1) and (2) of section 1.2 of the the Scala spec it's clear why this is happening. In the first case the final token (']') of the error line can terminate a statement and the first token of the following line ('{') can begin a new statement ... so a statement separator is inserted between the two and the compiler complains that I'm trying to instantiate an abstract trait. While I appreciate that this behaviour is probably horribly awkward to change, I'm a little bit peeved that I don't seem to have any choice but to switch to K&R style in these sorts of situations. Is there anything that can be done? [1] http://en.wikipedia.org/wiki/Indent_style Cheers, Miles |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Any way to cut down on memory footprint?: 00413, Warren Henning |
|---|---|
| Next by Date: | Re: two things about defs: 00413, Alexander Sergeev |
| Previous by Thread: | Any way to cut down on memory footprint?i: 00413, Warren Henning |
| Next by Thread: | Re: Brace style bias?: 00413, Raphael Cohn |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |