Sigh... I screwed up the example code. Here's a fixed version:
(use-modules (oop goops)
(srfi srfi-111))
(define-class ())
(define (boxed-slot? slot)
(get-keyword #:box? (slot-definition-options slot)))
(define-method (compute-getter-method (class ) slot)
(if (boxed-slot? slot)
(make
#:specializers (list class)
#:procedure (let ((slot-name (slot-definition-name slot)))
(lambda (obj)
(unbox (slot-ref obj slot-name)))))
(next-method)))
(define-method (compute-setter-method (class ) slot)
(if (boxed-slot? slot)
(make
#:specializers (list class )
#:procedure (let ((slot-name (slot-definition-name slot)))
(lambda (obj value)
(set-box! (slot-ref obj slot-name) value))))
(next-method)))
(define-class ( ))
(define-class ()
(bar #:accessor bar #:box? #t #:init-form (box 123))
#:metaclass )
(define-class ()
(bar #:accessor bar #:box? #t #:init-form (box 123))
#:metaclass )
;; This works:
(pk (+ (bar (make )) 456))
;; This throws an error:
(pk (+ (bar (make )) 456))
Attached is a quick patch I threw together that makes the example code
work. Did I find a bug???
- Dave