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
Copy file name to clipboardExpand all lines: changeLog.md
+9-1Lines changed: 9 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,13 @@
1
1
# Change Log
2
2
3
+
## v0.4.0
4
+
5
+
- Supports nested unpacking.
6
+
7
+
## v0.3.2
8
+
9
+
- Implements hack to enable rest unpacking after `var`. i.e. `[var _ as *a, b] <- someSeq`
10
+
3
11
## v0.3.1
4
12
5
13
- Renames rename syntax. From the originally confusing `{name: anotherName} <- tim` and `unpackObject(name = anotherName)` to clear and descriptive `as` for both. (i.e. `{name as anotherName} <- tim` and `unpackObject(name as anotherName)`.)
@@ -10,7 +18,7 @@
10
18
11
19
## v0.2.0
12
20
13
-
- Deprecating `unpack`, `lunpack`, and `vunpack` in favor of `unpackObject`, `unpackSeq`, `aUnpackObjec`, and `aUnpackSeq`. The new interface is more similar to the `<-` syntax, and the programmers will have more control over how the data source will be unpacked.
21
+
- Deprecating `unpack`, `lunpack`, and `vunpack` in favor of `unpackObject`, `unpackSeq`, `aUnpackObject`, and `aUnpackSeq`. The new interface is more similar to the `<-` syntax, and the programmers will have more control over how the data source will be unpacked.
14
22
15
23
- Adds example and tests to demonstrate how to flexibly unpack named tuples (like a boss).
See [tests/theTest.nim](tests/theTest.nim) for more usages.
@@ -188,10 +195,26 @@ Under the hood, `unpack` just attaches `[countFromStart..^countFromEnd]` to what
188
195
189
196
Unless you implement the `..` operator (and its friends) yourself though.
190
197
191
-
##### Only one rest operator per unpack
198
+
##### Only one rest operator per unpacked sequence
192
199
193
200
`[*a, *b, c] <- someSeq` is not allowed. It might be possible, but I think it will be really messy (plus I am lazy). Same restriction applies to both Python and JavaScript, so I think it's okay to skip this part for now.
194
201
202
+
However, using rest operator in different parts of the nested sequence is fine, since they have different index counters, so this will work:
203
+
204
+
```nim
205
+
[[*a, b], [c, d, *e], *f, g, h] <- someNestedSeq
206
+
# is expanded into:
207
+
# let
208
+
# b = someNestedSeq[0][^1]
209
+
# a = someNestedSeq[0][0..^2]
210
+
# c = someNestedSeq[1][0]
211
+
# d = someNestedSeq[1][1]
212
+
# e = someNestedSeq[1][2..^1]
213
+
# h = someNestedSeq[^1]
214
+
# g = someNestedSeq[^2]
215
+
# f = someNestedSeq[2..^3]
216
+
```
217
+
195
218
##### Can't guard against incorrect index access at compile time
196
219
197
220
Since we have no way to know the sequence length at compile time, (well, at least I don't know a way). We can't know if you are trying to do something goofy like:
0 commit comments