emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#46175: closed (Redefinable classes clobber custom slot options)


From: GNU bug Tracking System
Subject: bug#46175: closed (Redefinable classes clobber custom slot options)
Date: Sat, 20 Mar 2021 19:03:02 +0000

Your message dated Sat, 20 Mar 2021 20:02:29 +0100
with message-id <87lfahwsvu.fsf@pobox.com>
and subject line Re: bug#46175: Redefinable classes clobber custom slot options
has caused the debbugs.gnu.org bug report #46175,
regarding Redefinable classes clobber custom slot options
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs@gnu.org.)


-- 
46175: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=46175
GNU Bug Tracking System
Contact help-debbugs@gnu.org with problems
--- Begin Message --- Subject: Redefinable classes clobber custom slot options Date: Fri, 29 Jan 2021 11:43:35 -0500
The compute-slots method for <redefinable-class> does a transformation
of #:allocation #:instance slots to #:allocation #:virtual slots, but
in doing so it discards all slot options besides the standard ones.
This means that a metaclass that inherits from <redefinable-class>
won't work as expected if it relies upon custom slot options.

Test case:

    (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 patch that preserves all slot options that redefinable
classes do not need to alter, including custom ones.  How does it
look?

- Dave

Attachment: 0001-goops-Preserve-all-slot-options-in-redefinable-class.patch
Description: Text Data


--- End Message ---
--- Begin Message --- Subject: Re: bug#46175: Redefinable classes clobber custom slot options Date: Sat, 20 Mar 2021 20:02:29 +0100 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
On Fri 29 Jan 2021 17:43, "Thompson, David" <dthompson2@worcester.edu> writes:

> The compute-slots method for <redefinable-class> does a transformation
> of #:allocation #:instance slots to #:allocation #:virtual slots, but
> in doing so it discards all slot options besides the standard ones.
> This means that a metaclass that inherits from <redefinable-class>
> won't work as expected if it relies upon custom slot options.

Thanks for the report; patch applied!

Andy


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]