[Top][All Lists]

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

The :protection option for EIEIO slots

From: Stefan Monnier
Subject: The :protection option for EIEIO slots
Date: Thu, 15 Jan 2015 22:00:17 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

Hi Eric,

Can you give me some background on the :protection option for the slots
of EIEIO objects?  This doesn't exist in CLOS, so I'm wondering what
were the motivations to add them.

According to my grepping, the `private' setting is only used in the
eieio-tests.  And the `protected' setting is used at a few places, but
it's been implemented wrong so you can do:

  (defmethod foo ((x class-1))
    (slot-value <any-object> <any-protected-slot>))

and the access will be allowed, even though only protected slots
belonging to class-1 (or its superclasses) should be granted access.
This is because the code was the check was:

         ((and (eq (cdr fsym) 'protected)
               (or (child-of-class-p class (eieio--scoped-class))
                   (and (eieio-object-p obj)
                        (child-of-class-p class (eieio--object-class-object 

Which can be (and has been) rewritten to:

         ((and (eq (cdr fsym) 'protected)
               (or (child-of-class-p class (eieio--scoped-class))
                   (and (eieio-object-p obj)
                          (cl-assert (eq class (eieio--object-class-object 

Since all callers of the function guarantee that the assertion won't fail.

So I'm tempted to just drop this functionality.  Any thoughts?


reply via email to

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