# Re: Line Continuations for +/- Prefixed Numerics

No replies
John Nilsson
Joined: 2008-12-20,
Sorry, that borken setence shuold be:  "this must be _the best_ approach"

BR,
John

On Mon, Sep 5, 2011 at 3:01 AM, John Nilsson <john [at] milsson [dot] nu> wrote:
A big thumbs up for that one! :-)

I wasn't aware that the scala compiler could distinguish pure expressions from non-pure ones. Given that it apparently does, this must be approach.

Thinking about pureness, is it possible (or would it be much work to add?) to enforce CQS[1] using this analysis? Not in the language spec, just as an option to the compiler.

[1] http://en.wikipedia.org/wiki/Command-query_separation

Or thinking even further is this a step towards contracts? [2]

[2] http://msdn.microsoft.com/en-us/devlabs/dd491992

BR,
John

On Mon, Sep 5, 2011 at 2:18 AM, Paul Phillips <paulp [at] improving [dot] org> wrote:
On 9/4/11 4:06 AM, Daniel Duckworth wrote:
Consider the following line of code:

val a = 1
+ 2
- 4

Some of the comments in this thread have been, um, less than helpful. To me it should not be controversial that if the compiler sees you doing something useless, it should clue you in if it can.

% scala
Welcome to Scala version 2.10.0.r25608-b20110904171209 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_26).
Type in expressions to have them evaluated.

scala> class A {
| val a = 1
|     + 2
|     - 4
| }
<console>:9: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses
+ 2
^
<console>:10: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses
- 4
^
defined class A