This page is no longer maintained — Please continue to the home page at www.scala-lang.org

using prefix operators as identifiers

2 replies
Yuvi Masory
Joined: 2010-12-22,
User offline. Last seen 1 year 27 weeks ago.
I haven't seen anything in the spec that justifies this behavior:

scala> val ~ = 5~: Int = 5scala> println(~)<console>:1: error: illegal start of simple expression        println(~)                ^
It affects all the prefix method names (+, -, ~, !).
Unless I missed something in the spec this is either a problem with the spec or with the parser. Any thoughts before I file a bug report?
Yuvi

mepcotterell
Joined: 2011-03-17,
User offline. Last seen 40 weeks 6 days ago.
Re: using prefix operators as identifiers

Aren't those identifiers reserved?

Yuvi Masory
Joined: 2010-12-22,
User offline. Last seen 1 year 27 weeks ago.
Re: using prefix operators as identifiers
Hi Michael,
According to section 1.1 of the spec, no they are not reserved. Additionally, if they were reserved the val assignment would not succeed.
scala> val class = 1<console>:1: error: illegal start of simple pattern       val class = 1
Yuvi

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland