* Re: CL compatibility question
[not found] <mailman.3786.1083877034.1061.help-gnu-emacs@gnu.org>
@ 2004-05-06 21:53 ` Lawrence Mitchell
2004-05-06 21:56 ` Stefan Monnier
2004-05-06 22:02 ` Miles Bader
2 siblings, 0 replies; 4+ messages in thread
From: Lawrence Mitchell @ 2004-05-06 21:53 UTC (permalink / raw)
Joe Corneli wrote:
[...]
> In ELISP, not so great.
> (defbashfun taco (beef beans)
> (car $@))
> (taco t nil)
> ;=> Debugger entered--Lisp error: (wrong-number-of-arguments
> (lambda (name lambda &body body) (\` (defun (\, name) (&rest
> $@) (apply (lambda (\, lambda) (\,@ body)) $@)))) 3)
This is because &body isn't a recognised lambda list keyword in
emacs lisp. If you want to use full CL-style lambda lists in
DEFUN and DEFMACRO forms, you should do:
(require 'cl)
and use the DEFUN* and DEFMACRO* forms (note star).
(defmacro* defbashfun (name lambda &body body)
`(defun ,name (&rest $@)
(apply (lambda ,lambda ,@body) $@)))
(defbashfun taco (beef beans) (car $@))
(taco t nil) => t
Alternately, define defbashfun as:
(defmacro defbashfun (name lambda &rest body)
...)
[...]
--
Lawrence Mitchell <wence@gmx.li>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: CL compatibility question
[not found] <mailman.3786.1083877034.1061.help-gnu-emacs@gnu.org>
2004-05-06 21:53 ` CL compatibility question Lawrence Mitchell
@ 2004-05-06 21:56 ` Stefan Monnier
2004-05-06 22:02 ` Miles Bader
2 siblings, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2004-05-06 21:56 UTC (permalink / raw)
> (defmacro defbashfun (name lambda &body body)
^^^^^
This does not exist in `defmacro'.
You can use (require 'cl) and then `defmacro*' which supports &body IIRC.
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: CL compatibility question
[not found] <mailman.3786.1083877034.1061.help-gnu-emacs@gnu.org>
2004-05-06 21:53 ` CL compatibility question Lawrence Mitchell
2004-05-06 21:56 ` Stefan Monnier
@ 2004-05-06 22:02 ` Miles Bader
2 siblings, 0 replies; 4+ messages in thread
From: Miles Bader @ 2004-05-06 22:02 UTC (permalink / raw)
Joe Corneli <jcorneli@math.utexas.edu> writes:
> (defmacro defbashfun (name lambda &body body)
> `(defun ,name (&rest $@)
> (apply (lambda ,lambda ,@body) $@)))
...
> Why is this? Are there plans that would change this behavior in the
> future?
Use &rest, not &body (in CL, &body is really just &rest with a hint to
the pretty-printer).
-Miles
--
[|nurgle|] ddt- demonic? so quake will have an evil kinda setting? one that
will make every christian in the world foamm at the mouth?
[iddt] nurg, that's the goal
^ permalink raw reply [flat|nested] 4+ messages in thread
* CL compatibility question
@ 2004-05-06 19:36 Joe Corneli
0 siblings, 0 replies; 4+ messages in thread
From: Joe Corneli @ 2004-05-06 19:36 UTC (permalink / raw)
Frode Vatvedt Fjeld suggested (on comp.lang.lisp, 2004-05-06) the
following approach to building something like Bash's `$@' in LISP:
(defmacro defbashfun (name lambda &body body)
`(defun ,name (&rest $@)
(apply (lambda ,lambda ,@body) $@)))
In CLISP, this works great.
(defbashfun taco (beef beans)
(car $@))
(taco t nil)
;=> T
In ELISP, not so great.
(defbashfun taco (beef beans)
(car $@))
(taco t nil)
;=>
Debugger entered--Lisp error: (wrong-number-of-arguments (lambda (name lambda &body body) (\` (defun (\, name) (&rest $@) (apply (lambda (\, lambda) (\,@ body)) $@)))) 3)
(lambda (name lambda &body body) (\` (defun ... ... ...)))(taco (beef beans) (car $@))
(defbashfun taco (beef beans) (car $@))
eval((defbashfun taco (beef beans) (car $@)))
eval-last-sexp-1(nil)
eval-last-sexp(nil)
* call-interactively(eval-last-sexp)
Why is this? Are there plans that would change this behavior in the
future?
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-05-06 22:02 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <mailman.3786.1083877034.1061.help-gnu-emacs@gnu.org>
2004-05-06 21:53 ` CL compatibility question Lawrence Mitchell
2004-05-06 21:56 ` Stefan Monnier
2004-05-06 22:02 ` Miles Bader
2004-05-06 19:36 Joe Corneli
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.