nicholas.do...@hp.com wrote: > Tom Breton (Tehom) <te...@panix.com> wrote:
>> (let* >> ((x 1)) >> (eval-after-load 'simple (setq x 2)) >> x) >> >> =3D> 2 >> >> >> >> (let* >> ((x 1)) >> (eval-after-load 'simple '(setq x 2)) >> x) >> >> =3D> 1 > > > Are you sure about this? My understanding of this differs from > yours: This is definitely a "Boy is my face red" moment. You are completely correct. I had misunderstood `eval-after-load' as a macro. Upon looking at subr.el, it is obvious that you are right and I am wrong. Thank you for pointing all that out. > eval-after-load is an ordinary function (not a special form), and > function evaluation in most LISPs (elisp in particular) evaluates > arguments before the function is called on them. So if you give it an > unquoted form, the form will be evaluated *before* eval-after-load gets > its hands on it. That seems to me to defeat the purpose. I'd think that > the thing to do is to give the quoted form as argument, then function > evaluation evaluates the argument (i.e. unquotes the quoted form, > giving back the form) which is then passed to eval-after-load for > action. The semantics of eval-after-load imply that (depending on > whether the library is already loaded or not) the form may be evaluated > once. It is then squirrelled away and if the library is ever loaded > again, it is evaluated (perhaps for the first time, perhaps for the > nth), *after* the library is loaded. > > And I think your demonstration is misleading: after doing the > eval-after-load, you need to reload "simple" to trigger the "after-load" > evaluation, otherwise eval-after-load reduces to just plain eval (in > this particular case, since simple is, as you point out, already loaded - > things would be different if you had chosen some obscure library that > is not already loaded): > > (let* > ((x 1)) > (eval-after-load 'simple (setq x 2)) > (load-library "simple") > x) > 2 > > (let* > ((x 1)) > (eval-after-load 'simple '(setq x 2)) > (load-library "simple") > x) > 2 > > In the first case, (setq x 2) was evaluated, x was set to 2 and 2 was > passed into eval-after-load. Assuming that simple is already loaded, the > 2 is evaluated: the result is 2 and it is just thrown away. After the > library is loaded again, 2 is evaluated again and the result is 2 and it > just thrown away. Since x was set to 2 before, the value of x is 2. > > In the second case, (quote (setq x 2)) is evaluated, so the form (setq x > 2) is passed to eval-after-load. Assuming that simple is already loaded, > the form is evaluated, setting x to 2 and giving a result of 2 (which is > thrown away). After the library is loaded, (setq x 2) is eval'led again, > setting x to 2 again, and giving a result of 2 (which is thrown away). > > In both cases, the value of x (and therefore the value the let* form > returns) is 2. But it seems to me that the second case is the useful > one. > > Perhaps the most telling evidence that the quote should be there however > is the following: if you look at eval-after-load instances in the emacs > lisp directory, you'll see that the second argument in all of them is > quoted or at least (when partial evaluation is required) backquoted -- > although I guess one could argue that they all originated by copying a > badly constructed precursor - the programming version of original sin!-) > > Regards, > Nick > > _______________________________________________ Emacs-orgmode mailing list Remember: use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode