From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Declaring Lisp function types Date: Sat, 16 Mar 2024 16:06:08 +0200 Message-ID: <86sf0q5l0v.fsf@gnu.org> References: <87y1ajtl2h.fsf@neko.mail-host-address-is-not-set> <86wmq3732h.fsf@gnu.org> <87v85mthwz.fsf@neko.mail-host-address-is-not-set> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15643"; mail-complaints-to="usenet@ciao.gmane.io" Cc: acorallo@gnu.org, emacs-devel@gnu.org, stefankangas@gmail.com To: Tomas Hlavaty Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Mar 16 15:06:48 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 1rlUgR-0003rD-VU for ged-emacs-devel@m.gmane-mx.org; Sat, 16 Mar 2024 15:06:48 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rlUfu-0004h6-74; Sat, 16 Mar 2024 10:06:14 -0400 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 1rlUfs-0004fz-RF for emacs-devel@gnu.org; Sat, 16 Mar 2024 10:06:12 -0400 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 1rlUfs-0006sh-5Z; Sat, 16 Mar 2024 10:06:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=03OAZc6ZjIumUYKiZiQSLp+RmvVuBNXsQw6Vg76KFII=; b=rqgf5kyX4icRbdXsbC/1 j0GzaV20Bpe6AmLbJsEHa+Ullg01RLoqi7HqGqijY/D1uxFqC+F4JPx/HyPvoc+faaJ+xWidcyQQC HT/cgpQauEJDWWp7zfIS+mu77DWRJNatI1Z41Yj6GOA34GFVDvtpmSieFxE6T+PaB8J3zOjEf92mv vg2/NkwNhanYwaJy2BemULW16vn4rBRpFj33IAzg9Lv0S9qq8ALHGQmqiuJWTs1hb9J3L9L0AFsz/ T7wLKjqu4JXwLDTavZHU63/Nh6NHlXgYqhDmq4BarYpXHrtxAp+T3/Ou53TaiVYx36zT9q5rMRcAn LWqZH4/GZciIgw==; In-Reply-To: <87v85mthwz.fsf@neko.mail-host-address-is-not-set> (message from Tomas Hlavaty on Sat, 16 Mar 2024 14:39:24 +0100) 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:317114 Archived-At: > From: Tomas Hlavaty > Cc: acorallo@gnu.org, emacs-devel@gnu.org, stefankangas@gmail.com > Date: Sat, 16 Mar 2024 14:39:24 +0100 > > On Fri 15 Mar 2024 at 20:38, Eli Zaretskii wrote: > >> all cases are grep-unfriendly > > > > What do you mean by that? > > Please tell more: what would you like to grep for and why? > > Because good names help working with code bases. Yes, but who would search for names that are symbols of a programming language? If you search for "ptrdiff_t" or even "__attribute__", you get gobs of hits. Same if you search for "defun" or "defmac". This is simply not a good idea, and the fact that we choose this or that name for a type declaration will never help you, as long as many instances use that declaration. > In the context of "Declaring Lisp function types", grep gives too many > false positives when searching for the symbol 'function' or 'type'. It will give too many hits no matter how we call it. > Looking at > > (info "(elisp)Declare Form") > > there are examples of good and bad names for declare spec properties. > > Good; try searching for these: > > (rg "~/mr/emacs" "advertised-calling-convention") > (rg "~/mr/emacs" "side-effect-free") > (rg "~/mr/emacs" "no-font-lock-keyword") That's just sheer luck: not a lot of functions have these properties. By contrast, _every_ function will have some type and some signature, so you will have a gazillion of hits if you search for those, no matter what its name. > The symbol "function" already has specific meaning. Using it as a > declare spec property name is just bad. For example, eldoc or M-. shows > something unrelated to "Declaring Lisp function types". Some of these are irrelevant to the issue at hand, the others will have to be adapted to the change, if we care enough. > The other symbols do not show or lead to anything, those are dead-ends > magically doing something to the codebase without me being able to use > usual tools to understand and navigate them. This gap could be bridged > by defining dummy function/macro that would show the right arguments and > documentation and also display useful eldoc message. For example like > this: > > (defun side-effect-free (val) > "If VAL is non-‘nil’, this function is free of side effects, so > the byte compiler can ignore calls whose value is ignored. > This is the same as the ‘side-effect-free’ property of the > function’s symbol, *note Standard Properties::." > (error "side-effect-free is not meant to be called")) > > But maybe it would be possible to structure the code in such a way that > this dummy would not be needed, like the case of the symbol > "native-comp-speed" (if it was called native-comp-speed instead of > speed). > > Searching for no-font-lock-keyword does not show any declare definition. > Is it not used for anything? Sorry, you lost me here. How is this related to the issue discussed in this thread? > Elisp has great tools for navigating and understanding code, why work > against them? We don't.