From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: EIEIO default constructor function Date: Thu, 08 Apr 2021 00:44:15 -0400 Message-ID: References: <87y2e0rppp.fsf@blind.guru> <87ft06bwip.fsf@blind.guru> <87k0pi30kx.fsf@blind.guru> <87lf9t5twc.fsf@blind.guru> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17809"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Mario Lang Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Apr 08 06:45:29 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 1lUMXo-0004VU-PK for ged-emacs-devel@m.gmane-mx.org; Thu, 08 Apr 2021 06:45:28 +0200 Original-Received: from localhost ([::1]:40388 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lUMXn-0002xG-MS for ged-emacs-devel@m.gmane-mx.org; Thu, 08 Apr 2021 00:45:27 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57718) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lUMWs-0002XL-B6 for emacs-devel@gnu.org; Thu, 08 Apr 2021 00:44:30 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:18389) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lUMWp-0003tj-MW for emacs-devel@gnu.org; Thu, 08 Apr 2021 00:44:29 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 9757A80931; Thu, 8 Apr 2021 00:44:25 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id DFC9A8089E; Thu, 8 Apr 2021 00:44:23 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1617857063; bh=puJ1KOSnW5apbc7bvUkxD3Xj8ii9higuaF7ODC8NcTM=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=miGNOBj1MZgd1CelBjFiRraxK4nOJJi1Cb9GD/Jni4CgAZjw3dKS1oJ64QIEWXL0y WULL0gH3kV1mD3OvqRH/e50+VZyeRVGMfJbqiKT4d8Q/pp3WTReVH6M2zug+z64IkE LB6XwUPHCLD0gR632lAXjT5YkBI1gdQ1eaKfe3deWF/vSA9k9QBr/OI7j9Tk4gLp9o 5skd16b1FeEYODcfuw+57maKtaWPmFPpZMF4BvUIILkBtN1L/fZQnLfXSUgvNeVTdO jM8EwHGAmvE9uPzSiruIyjwoS442F0ormYNTrP2JH1LZlcE7A1gtmKCBCkVLn5R5Zc gpkszBbDrZsUg== Original-Received: from alfajor (104-222-126-84.cpe.teksavvy.com [104.222.126.84]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id B1C701201FC; Thu, 8 Apr 2021 00:44:23 -0400 (EDT) In-Reply-To: <87lf9t5twc.fsf@blind.guru> (Mario Lang's message of "Thu, 08 Apr 2021 05:37:07 +0200") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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:267595 Archived-At: > 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. I'd welcome patches to make them work with cl-structs. For `slot-value` this should be quite easy. For `make-instance` there are some choices to be made about the semantics we want to offer, so maybe it's not harder to implement but it requires more thought. > 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. Note you can also use things like: (cl-defstruct (my-foo (:constructor nil) (:constructor my-constructor-name (slot1 slot2 &aux (_ (when (> slot1 slot2)) (error "blabla"))))) slot1 slot2) which might cover some of that ground as well. I find those `&aux` thingies hideous, tho, so don't take this as a recommendation. AFAIK the only thing really missing is the ability to call-next-method to the parent's constructor, so the children's constructor either have to duplicate the work of their parent, or they have to manually call some ad-hoc function that encapsulates the work of the parent's constructor. I can imagine cases where it increases annoyingly the coupling between the parent and the child types, tho in my experience, this coupling is pretty much always tight for other reasons anyway, so it's never been a problem for me. Stefan