From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.help Subject: Re: EIEIO built in methods -- question Date: Sun, 09 Jun 2013 18:49:30 +0800 Message-ID: <87ppvv7e4l.fsf@ericabrahamsen.net> References: <87txl77fd3.fsf@ericabrahamsen.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1370774994 27009 80.91.229.3 (9 Jun 2013 10:49:54 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 9 Jun 2013 10:49:54 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Jun 09 12:49:54 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UldC4-00088Y-JN for geh-help-gnu-emacs@m.gmane.org; Sun, 09 Jun 2013 12:49:52 +0200 Original-Received: from localhost ([::1]:51710 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UldC4-0002Si-9D for geh-help-gnu-emacs@m.gmane.org; Sun, 09 Jun 2013 06:49:52 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46395) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UldBs-0002SR-Q3 for help-gnu-emacs@gnu.org; Sun, 09 Jun 2013 06:49:43 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UldBp-00020Z-VR for help-gnu-emacs@gnu.org; Sun, 09 Jun 2013 06:49:40 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:39681) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UldBp-00020R-Ow for help-gnu-emacs@gnu.org; Sun, 09 Jun 2013 06:49:37 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1UldBn-0007yt-Of for help-gnu-emacs@gnu.org; Sun, 09 Jun 2013 12:49:35 +0200 Original-Received: from 50.56.99.223 ([50.56.99.223]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 09 Jun 2013 12:49:35 +0200 Original-Received: from eric by 50.56.99.223 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 09 Jun 2013 12:49:35 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 35 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 50.56.99.223 User-Agent: Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:VjKN6u8pwOZa3uy4pzt9WotLdUc= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:91408 Archived-At: Eric Abrahamsen 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!