all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: "Eric M. Ludlam" <zappo@gnu.org>
Cc: emacs-devel@gnu.org
Subject: The :protection option for EIEIO slots
Date: Thu, 15 Jan 2015 22:00:17 -0500	[thread overview]
Message-ID: <jwvegqvtp4i.fsf-monnier+emacs@gnu.org> (raw)

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



             reply	other threads:[~2015-01-16  3:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-16  3:00 Stefan Monnier [this message]
2015-01-17  2:56 ` The :protection option for EIEIO slots Eric Ludlam
2015-01-17  3:56   ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvegqvtp4i.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=zappo@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.