[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: EIEIO: A question about interfaces
From: |
Michael Heerdegen |
Subject: |
Re: EIEIO: A question about interfaces |
Date: |
Fri, 15 Jan 2021 23:34:10 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Stefan Monnier <monnier@iro.umontreal.ca> writes:
> If you really might use all combinations, then maybe you should rather
> look at `my-foo-interface` as a separate type where one of its fields
> might be of type `my-1`, `my-2`, ...
Probably, yes.
But again: originally, all objects of the hierarchy would match the
method specifier `my-1`, objects of the new type would not, which may
cause (big) trouble.
I could make the new type to inherit from the interface class and
additionally also from my-1 to avoid this problem, but that would be
really weird, because when the my-1 base class would have default
field(s), they would exist twice in these kinds of objects. Note that
in my (hypothetical) scenario, I have no control how the `my-1`
subclasses are defined, say they are built in or provided by a library I
don't author, and also no way to change the code where the `my-1`
specifiers are used.
A cool solution would be if `make-instance' would allow to specify
multiple classes, or if I could alter an already existing object that is
an instance of my-17 (which stands for an arbitrary subclass of my-1) so
that is also becomes an instance of `my-foo-interface`, or at least
create a new object which is equal to the original object modulo my-17
behavior but is also an instance of the interface, in an ad hoc manner.
`class-of' could return a tuple of classes representing the ad-hoc
class. Everything else would behave as if I had explicitly created a
class for this kind of object inheriting from the according parent
classes.
Or could I instead extend the semantics of the `my-1` specifier to match
my "enriched" `my-1` objects?
Michael.