Shenghuo ZHU <zsh(a)cs.rochester.edu> writes:
> The attached file can be compiled in Emacs 20.5 but not in XEmacs
> 21.2.23. Any ideas?
Idea: the code is broken.
The (function NAME) special form is supposed to return the lexically
apparent function definition of NAME, where NAME may be a symbol or a
lambda expression. In Emacs, this boils down to just returning NAME
unevaluated.
What you're trying to do is, when you strip read-time syntactic
sugar, the following:
(function (backquote (lambda (arg2) (\, arg1))))
Obviously, the argument to FUNCTION is neither a symbol nor a lambda
expression. The interpreter groks it because `function' is exactly
the same as `quote'. The compiler needs to do more analysis, which is
why it gets to complain more.
What you want to do is:
(defun test-func (arg1)
`(lambda (arg2)
;; code here
,arg1))
The problem here is that the `;; code here' part will not be compiled.
If you don't have compunctions about using CL-isms, you can do this:
(defun test-func (arg1)
(lexical-let ((arg1 arg1))
(lambda (arg2)
;; code here, does get compiled.
arg1)))
When elisp becomes lexically scoped, the `lexical-let' part will not
be necessary.