I discussed this with Stefan off-list some time ago.
Still waiting for "dlet"... :)
Stefan Monnier wrote:
> > What to do about things like the calendar, where dynamic variables
> > with common names are an advertized part of the interface?
>
> Good question. I indeed looked at calendar as one of the first things
> where I tried to fix those top-level identifiers and bumped into this
> very problem, which kind of killed my motivation.
>
> > Eg diary-list-entries has always advertized NUMBER and ORIGINAL-DATE
> > as available for use in the hook functions it calls. It's widely used
> > within the calendar, and probably outside as well. It's not how I
> > would have implemented it, but here we are.
>
> > The only way I can think to change it is to make it respect both eg
> > DIARY-NUMBER and NUMBER equally, with a view to removing NUMBER in
> > future.
>
> I think in order to fix this, we're going to have to add a `dlet'
> (i.e. bind a variable dynamically even if it's not defvar'ed) construct
> of some sort. And/or maybe some way to specify additional dyn-bindings
> to `eval'.