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 23:22:33 +0800 Message-ID: <87hah771hi.fsf@ericabrahamsen.net> References: <87txl77fd3.fsf@ericabrahamsen.net> <87li6jjy81.fsf@kuiper.lan.informatimago.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1370791381 13569 80.91.229.3 (9 Jun 2013 15:23:01 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 9 Jun 2013 15:23:01 +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 17:23:02 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 1UlhSQ-000506-B1 for geh-help-gnu-emacs@m.gmane.org; Sun, 09 Jun 2013 17:23:02 +0200 Original-Received: from localhost ([::1]:44979 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UlhSP-0002lX-Qi for geh-help-gnu-emacs@m.gmane.org; Sun, 09 Jun 2013 11:23:01 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41223) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UlhSC-0002jq-6J for help-gnu-emacs@gnu.org; Sun, 09 Jun 2013 11:22:52 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UlhS6-0003p8-Gx for help-gnu-emacs@gnu.org; Sun, 09 Jun 2013 11:22:48 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:52490) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UlhS6-0003oJ-AV for help-gnu-emacs@gnu.org; Sun, 09 Jun 2013 11:22:42 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1UlhS2-0004mV-K4 for help-gnu-emacs@gnu.org; Sun, 09 Jun 2013 17:22:38 +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 17:22:38 +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 17:22:38 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 71 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:9HsI4n9pfOmTnWKdpzrZWVJyYp8= 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:91410 Archived-At: "Pascal J. Bourguignon" writes: > 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). > > That's because it just tries to emulate CLOS. Use the Hyperspec or > other Common Lisp tutorial or book covering OOP. > > http://www.lispworks.com/documentation/HyperSpec/Body/c_object.htm > > >> 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. > > All right. But what is it you want to do? > > >> 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? > > What "it"? > > >> Essentially, Python's "**kwargs" >> turns into "&rest slots" --> (apply 'call-next-method .... slots). > > Yes, lisp &rest has been translated to python **. > > >> I'd be interested in writing up a small introduction about how to use >> "internal" methods, ie methods on the eieio-default-superclass. > > The way to use "internal" methods is to NOT use them! > That's why they're internal, because external code don't, must not, > should not use them! > > So I still don't know what you want :-( Specifically: Override the initialization method for a class that inherits from eieio-persistent, to make sure that it's impossible to create two instances of the class that have the same :file slot. I've already realized constructor is the wrong method, so probably initialize-instance. Generally: If OO programming in (e)lisp is anything like OO programming in other languages, overloading initialization, deletion, and representation methods is *not* something to throw up our hands and wail about, it's a perfectly normal part of programming. See my specific example above. Unless I'm wrong about that, I'm offering to add a section to the manual detailing the right way to overload the basic methods on eieio-default-superclass, as a learning exercise for myself, if someone will agree to look at what I write, help me understand the issues correctly, and make sure what I write is accurate. That's all.