[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: EIEIO built in methods -- question
From: |
Eric Abrahamsen |
Subject: |
Re: EIEIO built in methods -- question |
Date: |
Sun, 09 Jun 2013 23:22:33 +0800 |
User-agent: |
Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.3 (gnu/linux) |
"Pascal J. Bourguignon" <pjb@informatimago.com> writes:
> 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).
>
> 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.
- EIEIO built in methods -- question, Eric Abrahamsen, 2013/06/09
- Re: EIEIO built in methods -- question, Eric Abrahamsen, 2013/06/09
- Re: EIEIO built in methods -- question, Pascal J. Bourguignon, 2013/06/09
- Re: EIEIO built in methods -- question,
Eric Abrahamsen <=
- Message not available
- Re: EIEIO built in methods -- question, Pascal J. Bourguignon, 2013/06/09
- Re: EIEIO built in methods -- question, David Engster, 2013/06/10
- Re: EIEIO built in methods -- question, Eric Abrahamsen, 2013/06/10
- Re: EIEIO built in methods -- question, David Engster, 2013/06/12
- Re: EIEIO built in methods -- question, Eric Abrahamsen, 2013/06/13
- Re: EIEIO built in methods -- question, Eric Abrahamsen, 2013/06/13
- Re: EIEIO built in methods -- question, David Engster, 2013/06/13
- Re: EIEIO built in methods -- question, Eric Abrahamsen, 2013/06/13
- Re: EIEIO built in methods -- question, David Engster, 2013/06/14
- Re: EIEIO built in methods -- question, Eric Abrahamsen, 2013/06/14