all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* The :protection option for EIEIO slots
@ 2015-01-16  3:00 Stefan Monnier
  2015-01-17  2:56 ` Eric Ludlam
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Monnier @ 2015-01-16  3:00 UTC (permalink / raw)
  To: Eric M. Ludlam; +Cc: emacs-devel

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



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-01-17  3:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-16  3:00 The :protection option for EIEIO slots Stefan Monnier
2015-01-17  2:56 ` Eric Ludlam
2015-01-17  3:56   ` Stefan Monnier

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.