On Wed, Mar 4, 2009 at 6:18 AM, Stefan Monnier
<monnier@iro.umontreal.ca> wrote:
> Say a file contains an add-hook form with a lambda argument:
> (add-hook 'foo-mode (lambda () (bar)))
> Annoyingly, the function will be added to the hook twice if the file
> is byte compiled, loaded, then reevaluated (such as with eval-buffer).
As a general rule, you should not put a lambda but a function name
(i.e. a symbol) instead, to avoid all those problems (and be able to
replace the function with a newer version of it). But occasionally
a lambda is really exactly what you want, of course.
i prefer this be transparent to the user as Geoff Gole suggested.
My reason is that from a user point of view, lambda serves the same purpose as function name, and one less thing to worry about problems that might come from byte compiling.
if the code suggested does fix this without any other problems, why not?
cheers,
Xah