[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: EIEIO: A question about interfaces
From: |
Stefan Monnier |
Subject: |
Re: EIEIO: A question about interfaces |
Date: |
Thu, 14 Jan 2021 12:47:39 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
[ Side note; I'm a functional programmer, so OO design is not something
I'm good at. Also, while I am familiar with the CLOS features and
semantics, I don't have much experience using it. ]
> Now I want to allow that some objects of some of these classes have/
> support an additional feature.
I think the idea is that those objects which support that extra feature
aren't really of the same type as those that don't, so you'd create
a new class for them.
In your example, that might mean you'd create a new class that inherits
from both `my-1` and `my-foo-interface`.
Of course, another approach is to not use the OO approach to
solve this problem but instead to use good'ol `if` tests, tho you'll
still need to store that `additional` info somewhere: you could add some
`extra-properties` to all your objects and store it there, tho depending
on the specifics there are likely to be various other options.
Stefan