emacs-devel
[Top][All Lists]
Advanced

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

Re: Support virtual slots in EIEIO


From: Stefan Monnier
Subject: Re: Support virtual slots in EIEIO
Date: Wed, 21 Nov 2018 09:50:57 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

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




reply via email to

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