> 0. I'm sure there is another way, but my mind blanks at the moment
After you got me started, I was able to simplify and generalize it a bit.
(-> is a GOOPS generic accessor I defined elsewhere. It works with
vectors, arrays, strings, etc ...)
(define-syntax with-accessors (lambda (stx) (syntax-case stx ()
((_ (id ...) exp ...) #`(begin #,@(let (;; checks if
arg is in the list of identifiers (id ...)
(in-list? (lambda (arg) (exists
(lambda (x) (bound-identifier=? x arg))
#'(id ...))))) ;; transform each expression in
exp ... (map (lambda (clause)
(syntax-case clause (set!) ;; setter
((set! (arg idx ...) val)
(in-list? #'arg) #'((setter ->) arg idx ...
val)) ;; getter ((arg
idx ...) (in-list? #'arg)
#'(-> arg idx ...)) (id #'id)))
#'(exp ...))))))))