This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: setf.scm






>* Using (setf! (...) ...) instead of (set! (...) ...) adds a
>needless top-level name, adds conceptual clutter, and is likely to
>lead to more silly mistakes (as people use one where they should
>have used the other).

Sounds reasonable.

>As a reminder of previous discussions:
 >(set! (PROC ARGS ...) RHS)
>is (in Kawa at least) equivalent to:
 >((setter PROC) RHS ARGS ...)
>(The RHS becomes the first arguemnt to the setter because of the
>need to support var-args functions.)

I'm just thinking from a CLOS point of view now...
Shouldn't it expand to something like...
(setter RHS PROC ARGS ...)    ?
Because if setter is a CLOS method, it would most likely want to dispatch
on the type of ARGS, especially ARG1. Therefore shouldn't it be one of the
arguments to allow dispatch? It also seems cleaner if the ARGS and PROC are
kept together. Procedure and arguments evaluated the same way and all that.

Thus a clos implementation might have..
(define-method setter ((value <top>) (proc <procedure>))
     (proc value))
And you might define...
(define-method address ((o <person>))
    (slot-ref o 'address))
(define-method address ((o <person>) (ad <string>))
    (slot-set! o 'address))

Or am I talking nonsense?