On Tue Oct 4 2016 Stefan Monnier wrote: > There are two ways to do that with lexical-binding: > - use (eval <form> `((<var1> . ,<val1>) (<var2> . ,<val2>) ...) > which will not give the exact same behavior but works well in many > cases (i.e. depends on the code put in diary-date-forms). > - use > > (defvar <var1>) (defvar <var2>) ... > (let ((<var1> <val1>) > (<var2> <val2>) > ...) > (eval <form> t)) > > which will preserve backward compatibility.
Thank you, I did not know that! - It appears to me that the first approach is the cleaner way to go. So I've tested it with bbdb-anniv.el, and it seems to do exactly the right thing. Under what circumstances could there be a problem? (The forms in diary-date-forms are lists containing symbols and strings. Then `eval' is applied to the list elements in order to replace the symbols by their let-bound values. So there is nothing fancy happening here. Possibly there is yet a completely different strategy for this problem? I just copied the relevant code from diary-list-entries-2, assuming that this should be the most reliable strategy for bbdb-anniv even if I do not know too much about diary-lib.el.) Actually, I am a bit confused about the second approach you suggested. I believe I understand its logic, though I find it odd to use defvar in such a context. Interestingly, the elisp manual says about `defvar': If SYMBOL is already lexically bound (e.g., if the ‘defvar’ form occurs in a ‘let’ form with lexical binding enabled), then ‘defvar’ sets the dynamic value. The lexical binding remains in effect until its binding construct exits. *Note Variable Scoping::. This suggests to me that in your second approach the defvar's could also go inside the let, which appears rather odd to me. Or am I misinterpreting this paragraph? What would be an example for this usage of defvar in a let form? Thanks again, Roland ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot _______________________________________________ bbdb-info@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bbdb-info BBDB Home Page: http://bbdb.sourceforge.net/