Conversation
Edited 1 month ago

kaslisp now has a set of syntactic sugar that I’m pretty proud of! (I stole it from Fennel lol)

you can access dict elements like this (. dict key) so for example to get the 'foo element you do (. dict 'foo), but you can also use the syntactic sugar dict.foo and the parser will turn it into (. dict 'foo) automatically!

there’s also a special case for (set) so that you can set dict keys with (set (. dict key) value) which means that you can intuitively (set dict.key value)!

but it’s even cooler than that, because when you (dofile) a kaslisp file, it will run everything in that file and then return the result of evaluating the very last form. so just like in Lua, you can make your file return a dict and that’s how importing works! for example:

; set the variable `some-lib` to the result of running `somelib.kaslisp` which happens to be a dict that's full of functions!
(local some-lib (dofile "lib/somelib.kaslisp"))

; this runs the function found at `(. some-lib 'some-func)`!
(some-lib.some-func)

#lisp

1
0
7

also I just added some more sophisticated stringifying logic so now when kaslisp is asked to print the list: (. (. foo (quote bar)) (quote baz)) it will print it as foo.bar.baz and when it’s asked to print (quote (foo bar baz)) it will print it as '(foo bar baz)

0
0
2