Clojure

(apply and [false true]) gives CompilerException

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Declined
  • Affects Version/s: Release 1.4, Release 1.5
  • Fix Version/s: None
  • Component/s: None
  • Labels:
  • Environment:
    Ubuntu 13.04. I run 1.4.0 by "apt-get install", and 1.5.1 by "java -cp clojure-1.5.1.jar clojure.main".

Description

user=> (apply and [false true])
CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.core/and, compiling:(NO_SOURCE_PATH:1)
user=> (apply and (list false true))
CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.core/and, compiling:(NO_SOURCE_PATH:2)

Activity

Hide
Cynthia Qiu added a comment -

I got it. "and" is not a function but a special form. Sorry for that.

Show
Cynthia Qiu added a comment - I got it. "and" is not a function but a special form. Sorry for that.
Hide
Andy Fingerhut added a comment -

Minor comment on yours: Clojure and other Lisps often distinguish between "special forms" and macros. I may be missing some of the distinction, but I am pretty sure the main part is that special forms are usually built into the implementation of Lisp, whereas macros are typically defined by the user via defmacro.

In any case, neither special forms nor macros may be used with apply, only functions.

Show
Andy Fingerhut added a comment - Minor comment on yours: Clojure and other Lisps often distinguish between "special forms" and macros. I may be missing some of the distinction, but I am pretty sure the main part is that special forms are usually built into the implementation of Lisp, whereas macros are typically defined by the user via defmacro. In any case, neither special forms nor macros may be used with apply, only functions.
Hide
Alex Miller added a comment -

As per Andy's comment, this is expected behavior when trying to apply to macros.

Show
Alex Miller added a comment - As per Andy's comment, this is expected behavior when trying to apply to macros.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: