Do any lisps have a s-expression as their head, e.g. ((f 2) 3 4)? If not, why?

前端 未结 3 1895
失恋的感觉
失恋的感觉 2021-01-12 11:24

Do any lisps support nested s-expression on their head? For example

((f 2) 3 4)

for which (f 2) presumably evaluates to a fun

3条回答
  •  北恋
    北恋 (楼主)
    2021-01-12 11:48

    In those Lisps, which have single namespace for variables and functions, your expression is valid. These are called Lisp-1. Scheme and Clojure are examples of such Lisps.

    In those Lisps, which have separate namespaces for variables and functions, your expression would be (funcall (f 2) 3 4). These are called Lisp-2. Common Lisp and Emacs Lisp are examples of such Lisps.

    In Lisp-2 every symbol has a value slot and a function slot. To call a function, that is stored in a value slot you need to use funcall keyword.

    See more on this issue: http://www.dreamsongs.com/Separation.html

    Edit: Thanks to Rainer Joswig i corrected the answer.

提交回复
热议问题