Is it possible to implement auto-currying to the Lisp-family languages?

前端 未结 6 2066
夕颜
夕颜 2020-12-31 06:15

That is, when you call a function with >1 arity with only one argument, it should, instead of displaying an error, curry that argument and return the resulting function with

6条回答
  •  忘掉有多难
    2020-12-31 06:43

    The short answer is yes, though not easily.

    you could implament this as a macro that wrapped every call in partial, though only in limited context. Clojure has some features that would make this rather difficult such as variable arity functions and dynamit calls. Clojure lacks a formal type system to concretely decide when the call can have no more arguments and should actually be called.

提交回复
热议问题