lantiga / ki

lisp + mori, sweet.js
ki-lang.org
MIT License
478 stars 28 forks source link

Keywords can't be treated as functions #29

Open jogrms opened 8 years ago

jogrms commented 8 years ago
ki require core
ki (:a {:a :b}) 

Results in

TypeError: keyword(...) is not a function

Example: http://ki-lang.org/editor/editor.html#ki%20require%20core%0Aki%20(:a%20%7B:a%20:b%7D)

lantiga commented 8 years ago

Yes, this is a known limitation, at least for now. Keywords cannot be evaluated in ki as they are in Clojure, you should use get in the meantime:

ki require core
return ki (get {:a :b} :a)
jogrms commented 8 years ago

Can we make the keyword function return a function?

lantiga commented 8 years ago

The keyword function currently returns a ClojureScript keyword object. We could indeed make keyword return a function and attach all properties of the keyword object to it (making it callable in a way), but this breaks things like equals, etc in mori. Any thoughts?