help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

EIEIO built in methods -- question


From: Eric Abrahamsen
Subject: EIEIO built in methods -- question
Date: Sun, 09 Jun 2013 18:22:48 +0800
User-agent: Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.3 (gnu/linux)

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).
There are several more I haven't experimented with, but that should be
documented.

If I make a documentation patch against the manual, will someone with
actual EIEIO/CLOS experience take a look at it?

Thanks!
Eric




reply via email to

[Prev in Thread] Current Thread [Next in Thread]