M2 icon indicating copy to clipboard operation
M2 copied to clipboard

Feature request: partial parallel assignment

Open mahrud opened this issue 4 years ago • 2 comments

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.

mahrud avatar Jan 02 '21 05:01 mahrud

That's a good idea.

DanGrayson avatar Jan 02 '21 14:01 DanGrayson

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

mahrud avatar Aug 27 '22 10:08 mahrud