Currently a function curried with Alexandria's curry
must be called with funcall
. However it is possible to set the new function's symbol-function
so that we can do without it and treat it like a real function. Illustrated on https://lispcookbook.github.io/cl-cookbook/functions.html#with-the-alexandria-library:
(defun adder (foo bar)
"Add the two arguments."
(+ foo bar))
(defvar add-one (alexandria:curry #'adder 1) "Add 1 to the argument.")
(funcall add-one 10) ;; => 11
(setf (symbol-function 'add-one) add-one)
(add-one 10) ;; => 11
;; and still ok with (funcall add-one 10)
Is there a good reason not to allow both styles ? This looks quite interesting to me in this context of currying.
ps: I did ask on Alexandria's issue tracker some 3 weeks ago
pps: https://gitlab.common-lisp.net/alexandria/alexandria/blob/master/functions.lisp#L116
Based on your comment, and looking at the issue, yes it would be "foolish" to change curry
so that it binds functions in the global namespace:
curry
, which would break existing codedefalias
. As you can see, the definition is a little more involved than using symbol-value
. See also the documentation.