JohnEarnest / ok

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

Assignment to slice #15

Closed refi64 closed 8 years ago

refi64 commented 9 years ago

K5:

ryan@DevPC-LX:~/stuff/ok$ rlwrap k5
2015.04.05 (c) arthur whitney
 l:1 2 3
 l[1 2]:3 3
 l
1 3 3

ryan@DevPC-LX:~/stuff/ok$ 

ok:

ryan@DevPC-LX:~/stuff/ok$ rlwrap nodejs repl.js
oK v0.1

  l:1 2 3
1 2 3
  l[1 2]:3 3
list expected, found number.

ryan@DevPC-LX:~/stuff/ok$ 
JohnEarnest commented 8 years ago

This particular case has been fixed, but there are some additional generalizations of slice assignment left to implement. For reference, this type of assignment in oK is desugared into an application of dmend:

  {l[1 2]:3 3}
{l:.[l;1 2;{[x;y]y};3 3]}

An example of a form of assignment which remains a known issue is:

  a:3 3#0;a[0 1;0 1]:2 2#!4
(2
 3
 0 0 0)

The correct result should be:

(0 1 0
 2 3 0
 0 0 0)

Dmend is quite complex, but we're getting there.