开发者

Is there a way to use a keyword as a function in Common Lisp, as one does in Clojure?

开发者 https://www.devze.com 2023-04-04 18:55 出处:网络
In Clojure one can write (:foo {:foo 3 :bar 5}) which evaluates to 3. Is there any way to extend Common Lisp so that a ke开发者_开发知识库yword will act as a function that looks itself up?There are

In Clojure one can write

(:foo {:foo 3 :bar 5})

which evaluates to 3. Is there any way to extend Common Lisp so that a ke开发者_开发知识库yword will act as a function that looks itself up?


There are no easy, obvious or trivial ways to do that in a general way in portable Common Lisp, AFAIK.

Related functionality (for arrays) was provided in some earlier Lisp dialects, but it was not included in Common Lisp.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号