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 Lisp function types Date: Sat, 24 Feb 2024 04:21:10 -0500 Message-ID: References: <389657c1-3bc5-4577-82a1-df4244ed5d58@alphapapa.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35782"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: emacs-devel@gnu.org To: Adam Porter Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Feb 24 10:22:10 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 1rdoET-00096w-Iv for ged-emacs-devel@m.gmane-mx.org; Sat, 24 Feb 2024 10:22:09 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdoDd-00056k-Fu; Sat, 24 Feb 2024 04:21:17 -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 1rdoDY-00056N-Co for emacs-devel@gnu.org; Sat, 24 Feb 2024 04:21:13 -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 1rdoDW-0001in-T6; Sat, 24 Feb 2024 04:21:11 -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=CiThYmsFKlR4GXZZIY7cplOpmuClJEVf10trx21gjX4=; b=X9ZFfQeBcvHFJ8/ZzobB xn5OW4RugPtAC4M5ef6cVl45L0K6WDhQyd/fya9DLcO17vBB1ZNSZ6viFdPQaxxFQVOAQ6tsK2sLV 9X8xPJEG42W0TCmu8LMXNjZn6R+GNgk/4HI+2Z7Sf5S3yYVOPwbtxRgg1hoklhVni/17V+jUNxMiS 1YQbYPFqIDmXC8iIEp5DydV8xkIfXmD5nFzUPL1h1V6YSGdiWioWpLCP99speYctNvufgh4Bz0gB3 wmXTX9bhvrdwKRbK+LsXjgt5J0opIRH5Jvkmy9SRgovNUeqesRVrJkluluSFH+KIyvw3vMReOtBIm GoqfLddgkxmfmw==; Original-Received: from acorallo by fencepost.gnu.org with local (Exim 4.90_1) (envelope-from ) id 1rdoDW-00081r-48; Sat, 24 Feb 2024 04:21:10 -0500 In-Reply-To: <389657c1-3bc5-4577-82a1-df4244ed5d58@alphapapa.net> (Adam Porter's message of "Fri, 23 Feb 2024 17:35:12 -0600") 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:316485 Archived-At: Adam Porter writes: > Hi Andrea, > >> Finally on top of 'scratch/func-type-decls' (where I there was already a >> similar work for primitives) I pushed some commits that allows for the >> following style: >> (defun sum (a b) >> (declare (function (integer integer) integer)) >> (+ a b)) >> I moved all function declaration out of 'comp-known-type-specifiers' >> and >> everything looks functional now. >> Before writing a ton of changelogs I thought was good to get some >> feedback anyway. WDYT? > > That looks nice to me. My only suggestion would be to change the > symbol `function` to `type`, i.e. > > (defun sum (a b) > (declare (type (integer integer) integer)) > (+ a b)) > > Because it would be more concise and descriptive. Hi Adam, I understand your point, probably I had to explain this better in my original mail. Fact is, we already use the form (function (ATYPES) RTYPE) as type specifier for functions. So (ftype (function (ATYPES) RTYPE)) would be the most correct form semantically, where `ftype` (or `type` or really what we prefer) would be the declaration which takes the type specifier as argument. Having (declare (function (integer integer) integer)) implies that the type specifier is a valid declaration as well, or IOW that declare understands as well type specifiers as a declaration, which I believe is fine. I personally find `function` more clear than `type`, but more importantly I think just having `type` instead of `function` would be harder to justify from a semantic POV. Thanks! Andrea