[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)
(eieio--scoped-class)
(or (child-of-class-p class (eieio--scoped-class))
(and (eieio-object-p obj)
(child-of-class-p class (eieio--object-class-object
obj)))))
Which can be (and has been) rewritten to:
((and (eq (cdr fsym) 'protected)
(eieio--scoped-class)
(or (child-of-class-p class (eieio--scoped-class))
(and (eieio-object-p obj)
(progn
(cl-assert (eq class (eieio--object-class-object
obj)))
t))))
Since all callers of the function guarantee that the assertion won't fail.
So I'm tempted to just drop this functionality. Any thoughts?
Stefan
- The :protection option for EIEIO slots,
Stefan Monnier <=