Barry Margolin <[EMAIL PROTECTED]> writes:
> In article <[EMAIL PROTECTED]>,
>  Pascal Bourguignon <[EMAIL PROTECTED]> wrote:
>> Write a defsetf-er for funcall!
>[...]
>> (define-setf-method funcall (fun &rest args)
>>   "setf-method for (funcall fun args...)"
>>   (let* ((vfun (eval fun))
>
> This won't work if the code is compiled.  SETF is expanded at compile 
> time, but you need to EVAL the variable at run time (and need to do it 
> each time through the loop).

Indeed.

One problem to implement a run-time setf funcall, is that setf-ers are
defined from the name of the function:

(defun example (cons) (car cons))
(defun set-example (cons value) 
       (format *trace-output* "set-example")
       (setf (car cons) value))

(setf (symbol-function 'test) (symbol-function 'example))

(setf (symbol-function test) (symbol-function example))
(defun set-test (cons value)
       (format *trace-output* "set-test")
       (setf (car cons) value))
(defsetf test set-test)

(setf x (cons 0 0))

[44]> (setf (example x) 1)
set-example
1
[45]> (setf (test    x) 2)

set-test
2

But:
(setf fun (function test))
(setf (funcall fun x) 1)

could not know whether to use set-example or set-test, 
for (and (eq fun (function example)) (eq fun (function test)))


To make (setf (funcall ...) ...) work, we'd have to associate the
setters to the function objects instead of the function names (the
symbols).

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GCS d? s++:++ a+ C+++ UL++++ P--- L+++ E+++ W++ N+++ o-- K- w--- 
O- M++ V PS PE++ Y++ PGP t+ 5+ X++ R !tv b+++ DI++++ D++ 
G e+++ h+ r-- z? 
------END GEEK CODE BLOCK------
_______________________________________________
Help-gnu-emacs mailing list
Help-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs

Reply via email to