From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Andrea Corallo Newsgroups: gmane.emacs.devel Subject: Re: Declaring primitive function types Date: Sun, 03 Mar 2024 03:57:55 -0500 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40453"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Stefan Monnier To: Stefan Monnier via "Emacs development discussions." Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Mar 03 09:58:06 2024 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 1rghfZ-000AJX-Jt for ged-emacs-devel@m.gmane-mx.org; Sun, 03 Mar 2024 09:58:05 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rghfS-0000wl-RA; Sun, 03 Mar 2024 03:57:58 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rghfR-0000vJ-JU for emacs-devel@gnu.org; Sun, 03 Mar 2024 03:57:57 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rghfR-0006Af-BL; Sun, 03 Mar 2024 03:57:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=eDcccNt0uiCsU7wiIZU4/p2mSX8u4BwZTC9CHSlAQgo=; b=UOp7P16Q9ichv3oLP8bt DGJQLQ6gogZVRSxvTYMu6dAblO1R/LVXLKbkIELC9QYUrDhy4oKVF5kiYHmrxbZvJnHr/ICTnA0S4 /GKOzdvSoBJjR1mlQSy3tzYuOSFkm3SdDl0EIPEyjI+hnqd4CwujYuBtOli5qsI0hOoxYDMR76ooo UtkdO3FU+4tK3X4Ad377uCFG2PiJGNIyh0ekHJu9vc+4LhjVcDHD9Uk+CI1UjaDi4d3N5h7Qj0rTZ fUhDFxBX9ouMzPBt2QCx/D29jftvX+bPdpLJ3gt7NjluWdhIU2msTnihbXsRBHqU2P7XT8pA1bwvI KjgEu2Up1ddKiQ==; Original-Received: from acorallo by fencepost.gnu.org with local (Exim 4.90_1) (envelope-from ) id 1rghfQ-0001kW-Pa; Sun, 03 Mar 2024 03:57:56 -0500 In-Reply-To: (Stefan Monnier via's message of "Sat, 02 Mar 2024 16:45:28 -0500") X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:316740 Archived-At: Stefan Monnier via "Emacs development discussions." writes: >> DEFUN ("arrayp", Farrayp, Sarrayp, 1, 1, 0, >> doc: /* Return t if OBJECT is an array (string or vector). */, >> (function (t) boolean)) >> (Lisp_Object object) >> { >> if (ARRAYP (object)) >> return Qt; >> return Qnil; >> } > > Everything else being equal (haha!), I'd vote to put the type *before* > the doc. But I guess you did it this way so we don't have to touch > the DEFUNs to which we don't add an annotation. That's correct, I wanted to minimize the diff of the patch. > I think it looks pretty good. > >> I guess another option would have been having the type in the doc >> argument (as for attributes) and have something like: >> >> DEFUN ("arrayp", Farrayp, Sarrayp, 1, 1, 0, >> doc: /* Return t if OBJECT is an array (string or vector). */ >> type: (function (t) boolean)) >> (Lisp_Object object) >> { >> if (ARRAYP (object)) >> return Qt; >> return Qnil; >> } >> >> This would complexify a little things as we'd need 'make-docfile' to >> parse it and generate something somewhere that we read afterwards. > > I'd much rather not go through `make-docfile`. > > You could probably still make it work without `make-docfile`, just by > tweaking `Fsubr_type` so it skips the "type:" before calling Fread. > >> I like the solution of the prototype for its simplicity but maybe people >> find the last one is more aesthetic? > > Not sure about "aesthetic", but the presence of `type:` does make it more > obvious what this is about. The number of arguments to DEFUN is high > enough that it's toeing the limits of BoA style. > > Another option along those lines would be: > > DEFUN ("arrayp", Farrayp, Sarrayp, 1, 1, 0, > doc: /* Return t if OBJECT is an array (string or vector). */ > ((type (function (t) boolean)))) > (Lisp_Object object) > > which could accommodate extensions like > > DEFUN (... > doc: /* ... */ > ((type (function (t) boolean)) > (obsolete "use pcase, of course" "24,1") > (usage (fn ARGS [DOCSTRING] [INTERACTIVE] BODY...)))) Okay thanks, I'll try to come-up with something that does not add a new argument to the macro. Andrea