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: Generalized set!


Klaus Schilling <Klaus.Schilling@home.ivm.de> writes:

> Mikael Djurfeldt writes:
>  > 
>  > 
>  > Note that I finally followed Maciej and others'  advice regarding the
>  > order of arguments.  It is most intuitive to have the expansion:
>  > 
>  >   (set! (PWS A1 ...) V) --> ((SETTER PWS) A1 ... V)
>  > 
>  > and it has the advantage of working with all setters except the
>  > current array-set! which I think should be modified.
>  > 
> Is it possible to make it work with the slot-set! in BOS (Bryan O. Sullivan's
> Scheme Object System for R4RS), or other third-party object systems?

Well, if you have a `slot-set!', I guess you have a `slot-ref' as
well.

Then you can write:

  (if (not (defined? 'old-slot-ref))
    (define old-slot-ref slot-ref))

  (define slot-ref (make-procedure-with-setter old-slot-ref slot-ref))

Now you can do:

  (set! (slot-ref obj slot) val)

which, I suppose, is what you wanted to do.