Hi!
I wonder if you are still willing to be bugged about these
things..... Anyway, if yes, here is a question:
`letf', as implemented by cl-macs, is suboptimal. It always works
like this (roughly):
`(let ((oldval VAR))
(unwind-protect
(progn
(setf VAR VALUE)
,@body)
(setf VAR oldval)))
While this works generally, for some defsetfs it is pretty wasteful.
For instance, it would be nice if:
(letf (((current-buffer) somebuffer))
...)
were transformed to:
(save-current-buffer
(set-buffer somebuffer)
...)
instead of the usual unwind-protect drill. It would be a win because
save-current-buffer is a subr in (X)Emacs 20. The same applies to
other cases, where it is a matter of correctness rather than
efficiency. For example, `specifier-instance' has `set-specifier' as
its setf method. This means that this:
(letf (((specifier-instance SPECIFIER VALUE DOMAIN)))
... code ...)
doesn't work as expected, because it expands to:
`(let ((oldval (specifier-instance SPECIFIER DOMAIN)))
(unwind-protect
(progn
(set-specifier SPECIFIER VALUE DOMAIN)
,@body)
(set-specifier SPECIFIER OLDVAL DOMAIN)))
However, the second `set-specifier' is incorrect, because it adds a
new specification to DOMAIN instead of removing the temporary one.
This `letf' should actually expand to:
(with-specifier-instance SPECIFIER VALUE DOMAIN
... code ...)
because with-specifier-instance knows how to handle this correctly.
So, is there a way to detach `letf' from `setf'? How does Common Lisp
handle this?
--
Hrvoje Niksic <hniksic(a)srce.hr> | Student at FER Zagreb, Croatia
--------------------------------+--------------------------------
Old numerical analysts never die, they just get disarrayed.
Show replies by date