JohnEarnest / ok

An open-source interpreter for the K5 programming language.
MIT License
585 stars 73 forks source link

refs vs values #63

Closed ngn closed 4 years ago

ngn commented 7 years ago

Indexed assignment treats variables as refs rather than values, i.e. it modifies them in place even when their refcount is >1

oK v0.1
 a:b:1 2 3
1 2 3
 b[2]:4
1 2 4
 a
1 2 4

I was expecting a to remain unchanged. Similarly with dicts:

 a:b:[k:0]
[k:0]
 b[`k]:1
[k:1]
 a
[k:1]
JohnEarnest commented 7 years ago

K6 has the following behavior:

 a:b:1 2 3
 b[2]:4
 b
1 2 4
 a
1 2 3

 a:b:(,`k)!,0
 b[`k]:1
 b
(,`k)!,1
 a
(,`k)!,0
JohnEarnest commented 4 years ago

Should be fixed.

At some point I need to totally rework the implementation of amend/dmend- they're a total mess.