Closed ngn closed 4 years ago
In k5, the flip
of a dictionary seems to be a bit of a special case that I'm still looking into. It seems that dictionary transposes may be treated as a special type:
d:[a:0 1;b:2 3]
+d
+[a:0 1;b:2 3]
@[a:0 1]
@[0 1]
@:[a:0 1]
99
@:+[a:0 1]
98
@:(+)
107
@:(+:)
106
Dictionary comparison with match
is a separate and clearer issue- that one should be easier to fix. In oK:
[a:0 1]~[a:0 1]
0
In k5:
[a:0 1]~[a:0 1]
1b
I'm puzzled by this bit:
@[a:0 1]
@[0 1]
The result looks like a curried @
(a "projection"). So k5 considers @[a:0 1]
an M-expression with assignment inside the brackets? Then how come +[a:0 1;b:2 3]
isn't equivalent to (a:0 1)+(b:2 3)
? It must be a special case, like $[if;then;else]
.
Dictionary literals result in some subtle syntactic ambiguity with indexing. It's still pretty hard to tell how much of k5's behavior in some corner cases is intentional and how much is a bug or unintended consequence of other features.
I understand the semantics of "flipping" a dictionary now. This is how you would create a "table" in k6. oK does not support tables (or key-tables) yet, so +d
is, intentionally, an identity operation. Closing.