Dict Support!

Dict support, finally. My array and dicts currently share the same syntax, like Python and PHP do. I now firmly believe this is not done in languages for “consistency”, but more because its really easy to be lazy and not add new grammar.

var d = dict()
d["i am text"] = "value1"
d[3] = "value2"
print("output1: %s\n" % (d["i am text"]))
print("output2: %s\n" % (d[3]))

output / disassembly:

output1: value1
output2: value2

.kstr   0    "dict"
.kstr   1    "d"
.kstr   2    "value1"
.kstr   3    "i am text"
.kstr   4    "value2"
.kstr   5    "output1: %s
"

.kstr   6    "print"
.kstr   7    "output2: %s
"

.kint   0    3

.main
   varref_ks  0
        call  0
        keep  1
   varreg_ks  1
      setvar  0
     push_ks  2
   varref_ks  1
      refval  0
     push_ks  3
       index  1
      setvar  0
     push_ks  4
   varref_ks  1
      refval  0
     push_ki  0
       index  1
      setvar  0
   varref_ks  1
      refval  0
     push_ks  3
       index  0
     push_ks  5
      format  1
   varref_ks  6
        call  1
        keep  0
   varref_ks  1
      refval  0
     push_ki  0
       index  0
     push_ks  7
      format  1
   varref_ks  6
        call  1
        keep  0
         ret  0

I think I need a keys() function and a foreach type of loop. After that, I think you can do most of the normal languagey things people are used to doing.

Posted in Blog