Aladdin - Scala Bugtracking
[#1032] project: compiler priority: low category: bug
submitter assigned to status date submitted
Nikolay Martin open 2007-03-30 23:09:56.0
subject [contrib #413] unapplied assignment works with val, but not var
code
val (a, b) = (1, 2)  // works fine: assigns a = 1, b = 2
var (a, b) = (1, 2)  // fails
what happened
scala> var (a, b) = (1, 3)
:2: error: identifier expected but '(' found.
var (a, b) = (1, 3)
    ^
what expected Assignment, as with val.
[back to overview]
Changes of this bug report
Nikolay  edited on  2007-03-30 23:11:11.0
contribution #413
Burak  edited on  2007-07-06 12:25:12.0
reassign to Martin. This is a general feature request that concerns all sorts of patterns, not just unapply. We could do it by encoding var pat(...x_i...) = rhs as val pat$ = rhs ...var x_i = x_i$ ... similar to what is done in for-comprehensions, i believe. The trouble is, this encoding is slightly cleverer than most other syntactic sugar, but for-comprehensions are even more complicated so i find nothing wrong with doing this.