[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Return
From: |
Stephen J. Turnbull |
Subject: |
Re: Return |
Date: |
Wed, 08 Dec 2010 01:14:34 +0900 |
David Kastrup writes:
> "Stephen J. Turnbull" <address@hidden> writes:
> > (add-hook captain-hook (defun sm-or-dak?-style-foo () (foo bar baz)))
In view of David's reaction, it looks like
(add-hook 'captain-hook (defun sm-style-foo () foo bar baz))
is a better guess, and fixes a syntax error in passing.
> > Eek. No point in using the return value of a defun (is it even
> defined?) like that if you can equally well use the function symbol.
Better yet, use both, which is what that idiom does. (defun returns
the defun'ed function symbol.)
(defun sm-style-foo () foo bar baz)
=> sm-style-foo
I use this in my init file in contexts like
(add-hook 'text-mode-hook
;; yes I know this function is already defined
(defun auto-fill-mode-on () (auto-fill-mode 1)))
Note that the defun serves a real purpose here; it makes the init file
"just enough" idempotent in the face of changes to the hook function
being added. If that were a lambda, not only would the definition of
the hook function be changed, but the original definition would remain
on the hook.
Embedding the defun in the argument might be considered excessively
cute.
- Re: Return, (continued)
- Re: Return, Fren Zeee, 2010/12/08
- Re: Return, Stefan Monnier, 2010/12/09
- Re: Return, Stephen J. Turnbull, 2010/12/09
- Re: Return, Stefan Monnier, 2010/12/09
- Re: Return, Stephen J. Turnbull, 2010/12/10
- Re: Return, Fren Zeee, 2010/12/23
- Re: Return, Stephen J. Turnbull, 2010/12/07
- Re: Return, David Kastrup, 2010/12/07
- Re: Return,
Stephen J. Turnbull <=
- Re: Return, tomas, 2010/12/07
- Re: Return, MON KEY, 2010/12/06
- Re: Return, Stephen J. Turnbull, 2010/12/07
- Re: Return, David Kastrup, 2010/12/07
- Re: Return, Stephen J. Turnbull, 2010/12/07
- Re: Return, Richard Stallman, 2010/12/08
- Re: Return, Daniel Colascione, 2010/12/10
- Keyword args (was: Return), Helmut Eller, 2010/12/10
- Re: Keyword args, Daniel Colascione, 2010/12/12
- Re: Keyword args, Helmut Eller, 2010/12/13