all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: Michael Heerdegen <michael_heerdegen@web.de>
Cc: help-gnu-emacs@gnu.org
Subject: Re: EIEIO: A question about interfaces
Date: Fri, 15 Jan 2021 14:56:52 -0800	[thread overview]
Message-ID: <87im7xajwr.fsf@ericabrahamsen.net> (raw)
In-Reply-To: <877dod25jx.fsf@web.de> (Michael Heerdegen's message of "Fri, 15 Jan 2021 23:34:10 +0100")

Michael Heerdegen <michael_heerdegen@web.de> writes:

> 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.

This looks to me like you might be able to define your own
specializer/generalizer which fires t when it sees an object that fits a
certain criteria. You wouldn't be able to affect the existing codebase
you're working with, but you could certainly do this for your own code.



  reply	other threads:[~2021-01-15 22:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-14 15:21 EIEIO: A question about interfaces Michael Heerdegen
2021-01-14 17:47 ` Stefan Monnier
2021-01-15 11:30   ` Michael Heerdegen
2021-01-15 16:21     ` Stefan Monnier
2021-01-15 22:34       ` Michael Heerdegen
2021-01-15 22:56         ` Eric Abrahamsen [this message]
2021-01-15 23:38         ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87im7xajwr.fsf@ericabrahamsen.net \
    --to=eric@ericabrahamsen.net \
    --cc=help-gnu-emacs@gnu.org \
    --cc=michael_heerdegen@web.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.