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: Distinguishing `consp` and `functionp` Date: Tue, 30 Jan 2024 18:13:20 -0500 Message-ID: References: <86msssble8.fsf@gnu.org> <86bk9448ai.fsf@gnu.org> <864jew40m3.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25205"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: emacs-devel@gnu.org To: =?windows-1252?B?Sm/jbyBU4XZvcmE=?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Jan 31 00:14:36 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 1rUxJL-0006HL-Th for ged-emacs-devel@m.gmane-mx.org; Wed, 31 Jan 2024 00:14:36 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rUxII-0001oc-5T; Tue, 30 Jan 2024 18:13:30 -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 1rUxIG-0001oT-N2 for emacs-devel@gnu.org; Tue, 30 Jan 2024 18:13:28 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rUxIE-0003yN-Lc for emacs-devel@gnu.org; Tue, 30 Jan 2024 18:13:28 -0500 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 6DA1C1000DA; Tue, 30 Jan 2024 18:13:23 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1706656402; bh=gMkOUMJRYfCPpSuBHST3tMdN2Sf2PnLJhhsAkBb8ut8=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=N2ztYEozPrP+obZR08jtmxQrpOuoaxOWOxCnmE0jbcnVMpFkEfilU71CAJ0KaBF+4 kDFzXjHE+VYuNrwnOV9JNR0x0QMynm40DfJTNuWDBf0urRLsvR4jnSm+3ItRG+vZ4R xGq/aok1fLN7KdCiIJ8/Pm0f+hf9n3cmvr4E646WfJWI2XBKuErPtPepsCIOGXWl3R hCxMJ0G1HKcucxmSDAkxzPeaVMplCpUlJydIuA0jXM9zsAUAElxgdJW+wXdY4Mju/Q aj9xvdjwWP4pdnaW/XiwSUr9iTuJ0RMNGCmlEUXy8qUAKypGNTR6h4uG4vf9Dm/P72 GO1jhZwkkn4uQ== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id F1C6F100054; Tue, 30 Jan 2024 18:13:21 -0500 (EST) Original-Received: from alfajor (104-222-119-131.cpe.teksavvy.com [104.222.119.131]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 8B4371204F5; Tue, 30 Jan 2024 18:13:21 -0500 (EST) In-Reply-To: (=?windows-1252?Q?=22Jo=E3o_T=E1vora=22's?= message of "Tue, 30 Jan 2024 22:24:39 +0000") 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action 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:315646 Archived-At: >> Yup. My impression is that this is sufficiently rare that we can afford >> to break it. Maybe experience will show me wrong, of course. > > I've definitely seen users post configs to Eglot's bug tracker where > lambdas appear incorrectly quoted. i.e. > > (add-to-list 'eglot-server-programs '(foo-mode . (lambda (..) ...))) Yes, that's very common and that's why I don't think we can drop support for that in `funcall`. What I hope is less common is for those cases to go through `functionp`. Of course, it also depends on happenstance of how the `functionp` test is written. E.g. for `eglot-server-programs` it seems that we will/would suffer because we start by testing `functionp` instead of first handling the non-function-like lists. >> We could also consider an intermediate step where `functionp` returns >> t but emits a warning. > Indeed, though in that case I'd make the funcall warn. I think it's there > that this proposed runtime warning ultimately matters and is useful > to help users correct their elisp. Runtime warnings are a bit icky though > :-| but better than nothing. We already have compile time warnings at those places where the compiler easily knows that the list should be a function, but for all those other cases (like `eglot-server-programs`), we don't have any tool currently other than run-time warnings. >> - it can give a wrong impression to a beginner, encouraging confusion. >> - it can occasionally hide an error, making debugging a bit more difficult. > Wouldn't you add "complicates type propagation, static analysis and > optimization" to that list? No. All these can be blissfully unaware of what `funcall` does when presented with a list starting with `lambda`. In theory, it's true that analysis&optimization could assume that *after* the `funcall` the argument was a valid function obeying `functionp`, but I suspect our analysis/optimization technology is pretty far from that level, and even if we were able to make that work, the potential for gains from such information seems vanishingly small. Stefan