* Support virtual slots in EIEIO
@ 2018-11-21 5:33 Yuan Fu
2018-11-21 14:50 ` Stefan Monnier
0 siblings, 1 reply; 2+ messages in thread
From: Yuan Fu @ 2018-11-21 5:33 UTC (permalink / raw)
To: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 1128 bytes --]
I'm working on a project that uses EIEIO. At some point, I need to declare
a virtual slot — one
that has a getter and a setter. Because EIEIO doesn't support it, I tried
to hack one by myself.
I overloaded slot accessor and (setf slot-accessor). Then some problem
arises:
1. initial arguments don't work, that's what I expected anyway and I can work
around that.
2. I couldn't overload `set-slot-value' and `slot-value' because they are
just aliases to `eieio-oset`
and `eieio-oref', which are functions. That, I can't work around (or I
think I can't?)
So, is there any possible workaround that can make `set-slot-value'
and `slot-value' work with my virtual slot hack? All I can do right now is
write something like "never
use these two functions with this slot!!!" in the documentation.
That being said, are you interested in adding virtual slots to EIEIO?
My naive approach would be make `eieio-oset' and `eieio-oref' generic
functions.
But I don't really know anything about EIEIO and Emacs
so I don't know how much impact will that give, except everything in
EIEIO becoming slower.
Yuan
[-- Attachment #2: Type: text/html, Size: 2660 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Support virtual slots in EIEIO
2018-11-21 5:33 Support virtual slots in EIEIO Yuan Fu
@ 2018-11-21 14:50 ` Stefan Monnier
0 siblings, 0 replies; 2+ messages in thread
From: Stefan Monnier @ 2018-11-21 14:50 UTC (permalink / raw)
To: emacs-devel
Hi,
> I'm working on a project that uses EIEIO. At some point, I need to
> declare a virtual slot — one that has a getter and a setter. Because
> EIEIO doesn't support it, I tried to hack one by myself.
Very interesting. I'm not very familiar with this, so in order to see
what's the best solution, could you help me with some context:
- How does this work in CLOS (or in other systems that gave you the
idea of a virtual slot ;-)?
- Why do you need such a virtual slot (what alternatives have you
considered and how bad were they)?
> 1. Initial arguments don't work, that's what I expected anyway and
> I can work around that.
Could you clarify what you mean by "initial arguments don't work"?
Can you add a method to `initialize-instance` or something like that?
> 2. I couldn't overload `set-slot-value' and `slot-value' because they
> are just aliases to `eieio-oset` and `eieio-oref', which are
> functions. That, I can't work around (or I think I can't?)
>
> So, is there any possible workaround that can make `set-slot-value'
> and `slot-value' work with my virtual slot hack?
IIRC you might be able to get what you want by adding a method to
`slot-missing`. This will not impact the normal performance of slot-value.
Stefan
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-11-21 14:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-21 5:33 Support virtual slots in EIEIO Yuan Fu
2018-11-21 14:50 ` Stefan Monnier
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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).