From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mario Lang Newsgroups: gmane.emacs.devel Subject: Re: EIEIO default constructor function Date: Thu, 08 Apr 2021 05:37:07 +0200 Message-ID: <87lf9t5twc.fsf@blind.guru> References: <87y2e0rppp.fsf@blind.guru> <87ft06bwip.fsf@blind.guru> <87k0pi30kx.fsf@blind.guru> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11716"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Apr 08 05:37:53 2021 Return-path: Envelope-to: ged-emacs-devel@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 1lULUO-0002vi-67 for ged-emacs-devel@m.gmane-mx.org; Thu, 08 Apr 2021 05:37:52 +0200 Original-Received: from localhost ([::1]:56032 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lULUN-0001hx-8T for ged-emacs-devel@m.gmane-mx.org; Wed, 07 Apr 2021 23:37:51 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44330) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lULTp-0001GO-2L for emacs-devel@gnu.org; Wed, 07 Apr 2021 23:37:17 -0400 Original-Received: from familiekainz.at ([37.187.20.171]:44996 helo=ns3035380.ip-37-187-20.eu) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lULTn-0003Ye-0k for emacs-devel@gnu.org; Wed, 07 Apr 2021 23:37:16 -0400 Original-Received: by ns3035380.ip-37-187-20.eu (Postfix, from userid 110) id 66DE7112F; Thu, 8 Apr 2021 03:37:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=blind.guru; s=mail; t=1617853029; bh=BrQnypt7lBHXqVqYwy+48ZW/mQUFT2GG+/uc0GuyOsw=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=oBxJAPn7XbSGPr/NtHltx0BQFlDCMiTwPntdF3sxv1CX61k3FLD33g6iKloSMKMGb 8u2iOEMszWhY7MYjmxS53lkLx3R0MxF2qd++hHPGA/wtln/GGUXhHY17D0VPIU116P Ckw6/hUvm+BQLZISd/bURPz666WkVIr/A3EMexRQ= Original-Received: from x1.blind.guru (84-115-55-45.cable.dynamic.surfer.at [84.115.55.45]) by ns3035380.ip-37-187-20.eu (Postfix) with ESMTPSA id 41A55111E; Thu, 8 Apr 2021 03:37:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=blind.guru; s=mail; t=1617853028; bh=BrQnypt7lBHXqVqYwy+48ZW/mQUFT2GG+/uc0GuyOsw=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=nPPIsu2OUX7/BDk1YLETbR6HOtFtGcfV3+AUUPksIKu5Yp88IWM0fz0EAgTy7DSq2 mhrT1MuN2uuoS0RITQtqO5Ry255yt07UodaV6f8Pv876MCLpuFWsUqD7WtXW7rfJ83 mXS5LxZirFqwJmlr1ptTJFbkcWt2TTWT7N6+3/eo= Original-Received: by x1.blind.guru (Postfix, from userid 1000) id B13FDE80BDC; Thu, 8 Apr 2021 05:37:07 +0200 (CEST) In-Reply-To: (Stefan Monnier's message of "Sun, 04 Apr 2021 10:12:48 -0400") Received-SPF: pass client-ip=37.187.20.171; envelope-from=mlang@blind.guru; helo=ns3035380.ip-37-187-20.eu X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:267594 Archived-At: Hi Stefan. Thanks a lot. :include is just what I was looking for. And while `make-instance' and `slot-value' are convenient, I guess I can work around not having them. Having `initialize-instance' would also have been convenient, but since I apparently only needed an :after method I ended up using the :constructor option to rename the generated constructor to indicate it is internal. So it appears I can actually do without `defclass' and friends. Stefan Monnier writes: >> Maybe I was using sloppy terminology, but as far as I can see, `cl-defst= ruct' >> can not have a parent relationship, so what I call inheritance-based >> dispatch isn't really possible with cl-defstruct? >> >> (defclass foo () ()) >> (cl-defmethod val ((foo foo)) 0) >> (defclass bar (foo) ()) >> (cl-defmethod val ((bar bar)) 1) > > (cl-defstruct (my-foo) > slot1) > (cl-defmethod my-val ((x my-foo)) (my-foo-slot1 x)) > (cl-defstruct (my-bar > (:include my-foo)) > slot2) > (cl-defmethod my-val ((x my-bar)) > (+ (my-bar-slot2 x) (cl-call-next-method))) > > (my-val (make-my-bar :slot1 4 :slot2 5)) > =3D=3D> 9 > > > -- Stefan --=20 CYa, =E2=A1=8D=E2=A0=81=E2=A0=97=E2=A0=8A=E2=A0=95