[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: run-hooks vs. run-mode-hooks.

From: Stefan Monnier
Subject: Re: run-hooks vs. run-mode-hooks.
Date: Fri, 27 May 2005 12:07:32 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

>   (if (fboundp 'function-in-doubt)
>       (defalias 'mymodule-function-in-doubt 'function-in-doubt)
>     (defun mymodule-function-in-doubt ...))

Actually this form has the disadvantage that the byte-compiler would have to
check which functions are defnied in every branch.  And snice it doesn't do
that as of now, the byte-compiler won't noticve that this form does define
`mymodule-function-in-doubt' and will hencforth issue warnings when you call
that function.

Better use:

   (defalias 'mymodule-function-in-doubt
     (if (fboundp 'function-in-doubt)
       (lambda (..) ...)))

which makes it trivially obvious that `mymodule-function-in-doubt' will
indeed always be defined.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]