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: Codifying some aspects of Elisp code style and improving pretty printer Date: Fri, 01 Oct 2021 13:08:28 -0400 Message-ID: References: <87o88bntv8.fsf@gmail.com> <87wnmyy29v.fsf@gmail.com> <871r56nlhd.fsf@gmail.com> <87v92hw7gq.fsf@gnus.org> <87a6js253t.fsf@gmail.com> <8735pk202x.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30141"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Lars Ingebrigtsen , Bozhidar Batsov , akater , Emacs Devel To: Robert Pluim Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Oct 01 19:09:24 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 1mWM2G-0007eu-11 for ged-emacs-devel@m.gmane-mx.org; Fri, 01 Oct 2021 19:09:24 +0200 Original-Received: from localhost ([::1]:45070 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mWM2F-0001qq-2i for ged-emacs-devel@m.gmane-mx.org; Fri, 01 Oct 2021 13:09:23 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53508) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWM1W-0000gg-Ca for emacs-devel@gnu.org; Fri, 01 Oct 2021 13:08:38 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:60054) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWM1S-0001yS-3v for emacs-devel@gnu.org; Fri, 01 Oct 2021 13:08:35 -0400 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 7C118440FA5; Fri, 1 Oct 2021 13:08:31 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id AB5094406B3; Fri, 1 Oct 2021 13:08:29 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1633108109; bh=4PFt9hwgmicyYj5hpfkUREHO4uZGiTrV9KHxC2MS3nk=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=XcFB2otgzvcws/wmRPB3K6N75kn+ZiHGLSl8IAIzU10wf2S2C7r4MLjiEnFKMXHxT o+t0rPH1ZzVm8Iw/ej3rWnuZIBoMg9pZnA4gTqvqt4+8YXcxBDL3OvpY6u2EPBM3Lj 4oyRxvCpYqBY40MEeTbV8noDalgDdxWqKsUBggGphBIgLRsJkTemPnE5buFPgULmGD LmXy2jsOdfsZJ7zCMejaByXMoQKGaebbPQL0BFq+KjZOB4j9FztPAFaPZgQCPiL1+k N1XfyiK52BaNxlvEnmNd09noiGWyYWUQwv0vp+dUEBvipzufqjSX6J6DlzUvCuZ34f JzEH+PjEyJj2w== Original-Received: from ceviche (modemcable004.216-203-24.mc.videotron.ca [24.203.216.4]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 7AD5B120172; Fri, 1 Oct 2021 13:08:29 -0400 (EDT) In-Reply-To: <8735pk202x.fsf@gmail.com> (Robert Pluim's message of "Fri, 01 Oct 2021 18:15:18 +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:275998 Archived-At: > All the examples there use 'quote', and the discussion of 'quote' vs > 'function' is in (info "(elisp) Anonymous Functions"). People who've > just gone 'i mapc' in the elisp manual have no reason to read that > second node. Patch below See comment below. > If dislike it, because I view lambda as self-quoting, but as you say > that=CA=BCs a personal preference (although "(elisp) Anonymous Functions" > kind of tells you not to quote lambda's). Quoting a lambda for me means to put a `quote` in front of it not a `function`. #' is a "translucent quote" which says this isn't some chunk of data (something the compiler basically can't touch nor "understand") but is a chunk of code (something which the compiler can definitely manipulate, analyze, etc...). > >> 3. The byte compiler doesn=CA=BCt warn about it. > > Stefan> Mine does ;-) > Stefan> But I wouldn't want to enable such a warning by default (or a= t least it > Stefan> should be mess a bit less eager than it is, because of the oc= casional false > Stefan> positives). > > I=CA=BCve not seen any false positives from mine, but I suspect it=CA=BCs= less > sophisticated than yours :-) Mine's very simple, but I think most of its false positives come from `define-key`. In any case I think the trade off between annoying coders with more warnings and the improvement in code quality we hope to get by fixing the code to eliminate the warnings is not in favor of adding this warning. At least not at this point. > diff --git a/doc/lispref/functions.texi b/doc/lispref/functions.texi > index c856557c3c..4416b39f09 100644 > --- a/doc/lispref/functions.texi > +++ b/doc/lispref/functions.texi > @@ -890,6 +890,33 @@ Mapping Functions > over a char-table in a way that deals properly with its sparse nature, > use the function @code{map-char-table} (@pxref{Char-Tables}). >=20=20 > + All the mapping functions described here take a function as their > +first argument, which can be specified in different ways: > + > +@itemize > +@item An anonymous lambda > + > +@example > +(mapcar (lambda (x) (x)) ....) > +@end example > + > +@item A function-quoted symbol > + > +@example > +(mapcar #'identity ....) > +@end example > + > +@item An quoted symbol > + > +@example > +(mapcar 'car ....) > +@end example > +@end itemize I don't see the point of documenting (mapcar 'foo ..) at this place. Also functions can be specified in many other ways (they can come from variable or be computed on the spot by calling a function-generating function, such as `apply-partially`). So I think it's better to link to some other place in the manual where we talk specifically about anonymous functions. More importantly, we should try and systematically use #'foo in all the examples instead. Also I wouldn't call it "a (function-)quoted symbol" but I'd say that we pass to mapcar a "function name" or maybe a "named function". We can elsewhere mention that 'foo also works to pass a (global) named function. Stefan