From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.help Subject: Re: EIEIO: A question about interfaces Date: Fri, 15 Jan 2021 23:34:10 +0100 Message-ID: <877dod25jx.fsf@web.de> References: <877dofee8e.fsf@web.de> <87turih1z8.fsf@web.de> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15921"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) To: help-gnu-emacs@gnu.org Cancel-Lock: sha1:3BWmHNbjzzlz/f63z668NiG67VI= Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jan 15 23:35:42 2021 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l0Xh0-00041j-B5 for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 15 Jan 2021 23:35:42 +0100 Original-Received: from localhost ([::1]:35690 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l0Xgz-0005OT-Dn for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 15 Jan 2021 17:35:41 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49806) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l0Xfe-0005O2-Cw for help-gnu-emacs@gnu.org; Fri, 15 Jan 2021 17:34:20 -0500 Original-Received: from ciao.gmane.io ([116.202.254.214]:50620) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l0Xfc-0000Ul-RF for help-gnu-emacs@gnu.org; Fri, 15 Jan 2021 17:34:18 -0500 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1l0Xfa-00027s-Ur for help-gnu-emacs@gnu.org; Fri, 15 Jan 2021 23:34:14 +0100 X-Injected-Via-Gmane: http://gmane.org/ Received-SPF: pass client-ip=116.202.254.214; envelope-from=geh-help-gnu-emacs@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.248, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:127266 Archived-At: Stefan Monnier 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.