From: Stefan Monnier <monnier@iro.umontreal.ca>
To: emacs-devel@gnu.org
Subject: Re: How to silence "Unknown slot" compiler warnings?
Date: Sat, 20 Feb 2016 21:05:23 -0500 [thread overview]
Message-ID: <jwvpovq7rmj.fsf-monnier+gmane.emacs.devel@gnu.org> (raw)
In-Reply-To: 87ziv17bd6.fsf@gmail.com
> I am always using :initarg with keywords because I want to emphasise
> slot names in main code:
> (defclass pm-polymode (pm-root)
> ((hostmode
> :initarg :hostmode
:hostmode is not a slot name, it's an initarg name. EIEIO is mostly an
implementation of CLOS, but for some reason it decided to allow you to
say (slot-value x :hostmode) instead of (slot-value x 'hostmode).
The two are equivalent, except that:
- (slot-value x :hostmode) is not accepted by CLOS.
- (slot-value x :hostmode) is slower.
> I can't say why! I'm also a little uncomfortable about the "naked"
> versions, and for the same reason -- my brain keeps seeing them as
> variables.
The "naked" version only shows up with (oref x hostmode) which is an
EIEIO-only macro which is equivalent to (slot-value x 'hostmode).
As you can see, the (slot-value x 'hostmode) version doesn't suffer from
this problem (and additionally it's part of CLOS), so I encourage you to
use that instead.
EIEIO can't take advantage of the compile-time-knowledge of `hostmode'
to speed up the slot access anyway, so you might as well use `slot-value'.
Both `oref' and `slot-value' are "namespace unclean" (they don't have
any kind of "package prefix"), but `oref' is a much more likely
candidate to obsolescence because `slot-value' at least has the argument
that it's a standard CLOS name.
Stefan
next prev parent reply other threads:[~2016-02-21 2:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-15 20:15 How to silence "Unknown slot" compiler warnings? Vitalie Spinu
2016-02-15 21:13 ` Stephen Leake
2016-02-16 0:22 ` Vitalie Spinu
2016-02-16 5:38 ` Eric Abrahamsen
[not found] ` <871t8dase0.fsf@gmail.com>
2016-02-16 14:15 ` Eric Abrahamsen
2016-02-16 14:51 ` Stephen Leake
2016-02-21 2:05 ` Stefan Monnier [this message]
2016-02-21 4:13 ` Eric Abrahamsen
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=jwvpovq7rmj.fsf-monnier+gmane.emacs.devel@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=emacs-devel@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.