From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: help-gnu-emacs@gnu.org
Subject: Re: EIEIO built in methods -- question
Date: Sun, 09 Jun 2013 18:49:30 +0800 [thread overview]
Message-ID: <87ppvv7e4l.fsf@ericabrahamsen.net> (raw)
In-Reply-To: 87txl77fd3.fsf@ericabrahamsen.net
Eric Abrahamsen <eric@ericabrahamsen.net> writes:
> There's not a lot of documentation out there about using EIEIO, so I
> want to check something. First of all I'm using emacs-version "24.3.1"
> (the archlinux package).
>
> This is so everyday in Python (the other language I have experience in)
> and so weird to me in (e)lisp that I'm experiencing a kind of cognitive
> clash, and want to make sure I'm not doing something very wrong. How does
> this look to anyone who knows EIEIO (or I guess CLOS)?:
>
> (defclass persistent-thing (eieio-persistent)
> ()
> :documentation "Just for testing, :file slot comes from the superclass")
>
> (defmethod constructor :static ((thing persistent-thing) newname &rest slots)
> (let ((filename (plist-get slots :file)))
> (when (member filename my-big-bad-list-of-filenames)
> (error "There's already a thing writing to %s" filename))
> (apply 'call-next-method thing newname slots)))
>
> Is this how we should be doing it? Essentially, Python's "**kwargs"
> turns into "&rest slots" --> (apply 'call-next-method .... slots).
>
> I'd be interested in writing up a small introduction about how to use
> "internal" methods, ie methods on the eieio-default-superclass. So far
> I've messed with constructor, destructor, object-print, and I guess
> initialize-instance (oooh, damn, I just realized I should probably be
> using initialize-instance rather than constructor in my above example).
If you use initialize-instance rather than constructor, it looks like
`slots' comes wrapped in an extra list layer, meaning you need (plist-get
(car slots) :file).
Hence the need for documentation!
next prev parent reply other threads:[~2013-06-09 10:49 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-09 10:22 EIEIO built in methods -- question Eric Abrahamsen
2013-06-09 10:49 ` Eric Abrahamsen [this message]
2013-06-09 11:54 ` Pascal J. Bourguignon
2013-06-09 15:22 ` Eric Abrahamsen
[not found] ` <mailman.1279.1370791373.22516.help-gnu-emacs@gnu.org>
2013-06-09 20:47 ` Pascal J. Bourguignon
2013-06-10 15:48 ` David Engster
2013-06-11 2:16 ` Eric Abrahamsen
2013-06-12 15:44 ` David Engster
2013-06-13 5:11 ` Eric Abrahamsen
2013-06-13 9:06 ` Eric Abrahamsen
2013-06-13 15:49 ` David Engster
2013-06-14 1:37 ` Eric Abrahamsen
2013-06-14 15:14 ` David Engster
2013-06-14 16:15 ` Eric Abrahamsen
[not found] ` <mailman.1680.1371226519.22516.help-gnu-emacs@gnu.org>
2013-06-14 18:29 ` Pascal J. Bourguignon
[not found] ` <mailman.1356.1370879310.22516.help-gnu-emacs@gnu.org>
2013-06-10 19:18 ` Pascal J. Bourguignon
2013-06-11 15:43 ` David Engster
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ppvv7e4l.fsf@ericabrahamsen.net \
--to=eric@ericabrahamsen.net \
--cc=help-gnu-emacs@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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).