M2
M2 copied to clipboard
Feature request: partial parallel assignment
Basically, would be good to get this to work:
i1 : (a, b, c) = (1, 2, 3)
o1 = (1, 2, 3)
o1 : Sequence
i2 : (a, , c) = (1, 2, 3)
-*dummy position*- error: syntax error: parallel assignment expected symbol
Usually it's just a convenient thing when you don't want to use an extra symbol, but sometimes the convenience is really worth it.
That's a good idea.
Same with this: (which is a strange error, by the way)
i1 : h = new MutableHashTable from {};
i2 : (h#0, h#1) = (0, 1);
stdio:2:3:(3): error: syntax error: parallel assignment expected symbol list
stdio:2:8:(3): error: syntax error: parallel assignment expected symbol
Also, some languages have a more syntax like this:
L = (0, 1, 2, 3, 4)
(a, b.., c, d) = L -- a=0, b=(1, 2), c=3, d=4
(a, b, c.., d) = L -- a=0, b=1, c=(2, 3), d=4
(a, b, .., d) = L -- a=0, b=1, d=4