ki icon indicating copy to clipboard operation
ki copied to clipboard

Keywords can't be treated as functions

Open jogrms opened this issue 9 years ago • 3 comments

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)

jogrms avatar Dec 08 '15 23:12 jogrms

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)

lantiga avatar Dec 10 '15 08:12 lantiga

Can we make the keyword function return a function?

jogrms avatar Dec 10 '15 18:12 jogrms

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?

lantiga avatar Dec 11 '15 21:12 lantiga