Christopher Allan Webber writes:
> I guess I never sent this to this list. Here's a functional setter for
> GOOPS classes.
Hah! Just this week I have been wondering the perceived absense of
functional setters (and figured I *must* have missed something
somewhere) and wrote
--8<---------------cut here---------------start------------->8---
(define ((identity-initializer o) name)
(list (symbol->keyword name) (slot-ref o name)))
(define-method (clone o . setters)
(let* ((class (class-of o))
(slots (class-slots class))
(names (map slot-definition-name slots))
(initializers (map (identity-initializer o) names))
(keywords (filter keyword? setters))
(initializers (filter (lambda (i) (not (memq (car i) keywords)))
initializers))
(initializers (append (apply append initializers) setters))
(arguments (cons class initializers)))
(apply make arguments)))
--8<---------------cut here---------------end--------------->8---
Usage:
(clone o #:slot <VALUE> ...)
Greetings,
Jan
--
Jan Nieuwenhuizen <[email protected]> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | AvatarĀ® http://AvatarAcademy.nl