Skip to main content
Bounty Awarded with 100 reputation awarded by 30468
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

Short Answer

Replace func2 with #'func2:

(defun func2 (arg)
  (if (listp arg)
      (mapcar #'func2 arg)
    arg))

Explanation

Emacs Lisp is a lisp-2 (like Common Lisp), not lisp-1 (unlike, say, Scheme)Emacs Lisp is a lisp-2 (like Common Lisp), not lisp-1 (unlike, say, Scheme).

I.e., every symbol in ELisp has a

  • "value cell": accessed by symbol-value, tested by boundp, and used by the compiler when the symbol is in the "variable" position, i.e., not as the first element of a list to be evaluated - like your use of func2.
  • "function cell": accessed by symbol-function, tested by fboundp, and used by the compiler when the symbol is in the "function" position, i.e., the first element of a list to be evaluated - like your use of func1.

Since func2 is in variable position and it has a function binding and not a variable binding, you are getting the void variable error. You need to tell the compiler to use the function value instead of the variable value, and this is accomplished by prefixing it with #' (you can use the ordinary quote 'ordinary quote ' instead too, but it is a bad idea because it makes code less readable and self-documenting).

See also Why use #' before function arguments in emacs-lisp?Why use #' before function arguments in emacs-lisp?

Short Answer

Replace func2 with #'func2:

(defun func2 (arg)
  (if (listp arg)
      (mapcar #'func2 arg)
    arg))

Explanation

Emacs Lisp is a lisp-2 (like Common Lisp), not lisp-1 (unlike, say, Scheme).

I.e., every symbol in ELisp has a

  • "value cell": accessed by symbol-value, tested by boundp, and used by the compiler when the symbol is in the "variable" position, i.e., not as the first element of a list to be evaluated - like your use of func2.
  • "function cell": accessed by symbol-function, tested by fboundp, and used by the compiler when the symbol is in the "function" position, i.e., the first element of a list to be evaluated - like your use of func1.

Since func2 is in variable position and it has a function binding and not a variable binding, you are getting the void variable error. You need to tell the compiler to use the function value instead of the variable value, and this is accomplished by prefixing it with #' (you can use the ordinary quote ' instead too, but it is a bad idea because it makes code less readable and self-documenting).

See also Why use #' before function arguments in emacs-lisp?

Short Answer

Replace func2 with #'func2:

(defun func2 (arg)
  (if (listp arg)
      (mapcar #'func2 arg)
    arg))

Explanation

Emacs Lisp is a lisp-2 (like Common Lisp), not lisp-1 (unlike, say, Scheme).

I.e., every symbol in ELisp has a

  • "value cell": accessed by symbol-value, tested by boundp, and used by the compiler when the symbol is in the "variable" position, i.e., not as the first element of a list to be evaluated - like your use of func2.
  • "function cell": accessed by symbol-function, tested by fboundp, and used by the compiler when the symbol is in the "function" position, i.e., the first element of a list to be evaluated - like your use of func1.

Since func2 is in variable position and it has a function binding and not a variable binding, you are getting the void variable error. You need to tell the compiler to use the function value instead of the variable value, and this is accomplished by prefixing it with #' (you can use the ordinary quote ' instead too, but it is a bad idea because it makes code less readable and self-documenting).

See also Why use #' before function arguments in emacs-lisp?

discourage single quote
Source Link
sds
  • 6.3k
  • 25
  • 41

Short Answer

Replace func2 with #'func2:

(defun func2 (arg)
  (if (listp arg)
      (mapcar #'func2 arg)
    arg))

Explanation

Emacs Lisp is a lisp-2 (like Common Lisp), not lisp-1 (unlike, say, Scheme).

I.e., every symbol in ELisp has a

  • "value cell": accessed by symbol-value, tested by boundp, and used by the compiler when the symbol is in the "variable" position, i.e., not as the first element of a list to be evaluated - like your use of func2.
  • "function cell": accessed by symbol-function, tested by fboundp, and used by the compiler when the symbol is in the "function" position, i.e., the first element of a list to be evaluated - like your use of func1.

Since func2 is in variable position and it has a function binding and not a variable binding, you are getting the void variable error. You need to tell the compiler to use the function value instead of the variable value, and this is accomplished by prefixing it with #' (you can use the ordinary quote ' instead too, but it is a bad idea because it makes code less readable and self-documenting).

See also Why use #' before function arguments in emacs-lisp?

Short Answer

Replace func2 with #'func2:

(defun func2 (arg)
  (if (listp arg)
      (mapcar #'func2 arg)
    arg))

Explanation

Emacs Lisp is a lisp-2 (like Common Lisp), not lisp-1 (unlike, say, Scheme).

I.e., every symbol in ELisp has a

  • "value cell": accessed by symbol-value, tested by boundp, and used by the compiler when the symbol is in the "variable" position, i.e., not as the first element of a list to be evaluated - like your use of func2.
  • "function cell": accessed by symbol-function, tested by fboundp, and used by the compiler when the symbol is in the "function" position, i.e., the first element of a list to be evaluated - like your use of func1.

Since func2 is in variable position and it has a function binding and not a variable binding, you are getting the void variable error. You need to tell the compiler to use the function value instead of the variable value, and this is accomplished by prefixing it with #'.

See also Why use #' before function arguments in emacs-lisp?

Short Answer

Replace func2 with #'func2:

(defun func2 (arg)
  (if (listp arg)
      (mapcar #'func2 arg)
    arg))

Explanation

Emacs Lisp is a lisp-2 (like Common Lisp), not lisp-1 (unlike, say, Scheme).

I.e., every symbol in ELisp has a

  • "value cell": accessed by symbol-value, tested by boundp, and used by the compiler when the symbol is in the "variable" position, i.e., not as the first element of a list to be evaluated - like your use of func2.
  • "function cell": accessed by symbol-function, tested by fboundp, and used by the compiler when the symbol is in the "function" position, i.e., the first element of a list to be evaluated - like your use of func1.

Since func2 is in variable position and it has a function binding and not a variable binding, you are getting the void variable error. You need to tell the compiler to use the function value instead of the variable value, and this is accomplished by prefixing it with #' (you can use the ordinary quote ' instead too, but it is a bad idea because it makes code less readable and self-documenting).

See also Why use #' before function arguments in emacs-lisp?

more info
Source Link
sds
  • 6.3k
  • 25
  • 41

Short Answer

Replace func2 with #'func2:

(defun func2 (arg)
  (if (listp arg)
      (mapcar #'func2 arg)
    arg))

Explanation

Emacs Lisp is a lisp-2 (like Common Lisp), not lisp-1 (unlike, say, Scheme).

I.e., every symbol in ELisp has a

  • "value cell": accessed by symbol-value, tested by boundp, and used by the compiler when the symbol is in the "variable" position, i.e., not as the first element of a list to be evaluated - like your use of func2.
  • "function cell": accessed by symbol-function, tested by fboundp, and used by the compiler when the symbol is in the "function" position, i.e., the first element of a list to be evaluated - like your use of func1.

Since func2 is in variable position and it has a function binding and not a variable binding, you are getting the void variable error. You need to tell the compiler to use the function value instead of the variable value, and this is accomplished by prefixing it with #'.

See also Why use #' before function arguments in emacs-lisp?

Short Answer

Replace func2 with #'func2:

(defun func2 (arg)
  (if (listp arg)
      (mapcar #'func2 arg)
    arg))

Explanation

Emacs Lisp is a lisp-2 (like Common Lisp), not lisp-1 (unlike, say, Scheme).

I.e., every symbol in ELisp has a

  • "value cell": accessed by symbol-value, tested by boundp, and used by the compiler when the symbol is in the "variable" position, i.e., not as the first element of a list to be evaluated
  • "function cell": accessed by symbol-function, tested by fboundp, and used by the compiler when the symbol is in the "function" position, i.e., the first element of a list to be evaluated

See also Why use #' before function arguments in emacs-lisp?

Short Answer

Replace func2 with #'func2:

(defun func2 (arg)
  (if (listp arg)
      (mapcar #'func2 arg)
    arg))

Explanation

Emacs Lisp is a lisp-2 (like Common Lisp), not lisp-1 (unlike, say, Scheme).

I.e., every symbol in ELisp has a

  • "value cell": accessed by symbol-value, tested by boundp, and used by the compiler when the symbol is in the "variable" position, i.e., not as the first element of a list to be evaluated - like your use of func2.
  • "function cell": accessed by symbol-function, tested by fboundp, and used by the compiler when the symbol is in the "function" position, i.e., the first element of a list to be evaluated - like your use of func1.

Since func2 is in variable position and it has a function binding and not a variable binding, you are getting the void variable error. You need to tell the compiler to use the function value instead of the variable value, and this is accomplished by prefixing it with #'.

See also Why use #' before function arguments in emacs-lisp?

add links
Source Link
sds
  • 6.3k
  • 25
  • 41
Loading
Source Link
sds
  • 6.3k
  • 25
  • 41
Loading