[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: MOP issues with <redefinable-class>
From: |
Thompson, David |
Subject: |
Re: MOP issues with <redefinable-class> |
Date: |
Fri, 29 Jan 2021 11:07:04 -0500 |
Sigh... I screwed up the example code. Here's a fixed version:
(use-modules (oop goops)
(srfi srfi-111))
(define-class <meta> (<class>))
(define (boxed-slot? slot)
(get-keyword #:box? (slot-definition-options slot)))
(define-method (compute-getter-method (class <meta>) slot)
(if (boxed-slot? slot)
(make <method>
#: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 <meta>) slot)
(if (boxed-slot? slot)
(make <method>
#:specializers (list class <top>)
#:procedure (let ((slot-name (slot-definition-name slot)))
(lambda (obj value)
(set-box! (slot-ref obj slot-name) value))))
(next-method)))
(define-class <redefinable-meta> (<meta> <redefinable-class>))
(define-class <foo> ()
(bar #:accessor bar #:box? #t #:init-form (box 123))
#:metaclass <meta>)
(define-class <redefinable-foo> ()
(bar #:accessor bar #:box? #t #:init-form (box 123))
#:metaclass <redefinable-meta>)
;; This works:
(pk (+ (bar (make <foo>)) 456))
;; This throws an error:
(pk (+ (bar (make <redefinable-foo>)) 456))
Attached is a quick patch I threw together that makes the example code
work. Did I find a bug???
- Dave
0001-goops-Preserve-all-slot-options-in-redefinable-class.patch
Description: Text Data