You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is pattern matching to variables only allowed during variable definitions, and not during var assignments?
E.g., this works:
val t = (1, 2)
var (a, b) = t
a = 1, b = 2
But,
var x = 10
var y = 20
(x, y) = t
Illegal start of definitio
Seems to be that pattern based assignment would also be quite useful???
Further comments: (from Burak on the mailing list)
This particular change would probably not require any changes to the matcher, rather to the frontend (parsing - desugaring - typechecking).
It would be translated as something like
var x = 10
var y = 20
match {
(x1, y1) => x = x1; y = y1;
}
The pattern matcher would never need to be aware of something being a mutable variable.
Burak
The text was updated successfully, but these errors were encountered:
@DRMacIver said:
As per discussion on mailing list, this is actually pretty complicated, particularly when combined with syntax sugar for updates. It will need a SIP.
Is pattern matching to variables only allowed during variable definitions, and not during var assignments?
E.g., this works:
val t = (1, 2)
var (a, b) = t
a = 1, b = 2
But,
var x = 10
var y = 20
(x, y) = t
Illegal start of definitio
Seems to be that pattern based assignment would also be quite useful???
Further comments: (from Burak on the mailing list)
This particular change would probably not require any changes to the matcher, rather to the frontend (parsing - desugaring - typechecking).
It would be translated as something like
var x = 10
var y = 20
match {
(x1, y1) => x = x1; y = y1;
}
The pattern matcher would never need to be aware of something being a mutable variable.
Burak
The text was updated successfully, but these errors were encountered: