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: Always-true predicate? Date: Fri, 19 Feb 2021 15:11:53 -0500 Message-ID: References: <875z2qoqc6.fsf@gnus.org> <87h7ma25so.fsf@tcd.ie> <8735xu33jy.fsf@gnus.org> <87lfbm1o5s.fsf@gnus.org> <874kiaxxbs.fsf@iki.fi> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15108"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: "Basil L. Contovounesios" , Lars Ingebrigtsen , emacs-devel@gnu.org To: Pip Cet Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Feb 19 21:13:00 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 1lDC95-0003oN-U6 for ged-emacs-devel@m.gmane-mx.org; Fri, 19 Feb 2021 21:12:59 +0100 Original-Received: from localhost ([::1]:48772 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lDC94-00079x-Un for ged-emacs-devel@m.gmane-mx.org; Fri, 19 Feb 2021 15:12:58 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51106) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lDC88-0006bp-H2 for emacs-devel@gnu.org; Fri, 19 Feb 2021 15:12:00 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:37647) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lDC85-0007KX-R0 for emacs-devel@gnu.org; Fri, 19 Feb 2021 15:11:59 -0500 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 1051A4413A8; Fri, 19 Feb 2021 15:11:56 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 5D91944038A; Fri, 19 Feb 2021 15:11:54 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1613765514; bh=x5u1Xrswxr0lGbG6EIdydhUlUOdb/zcDZ+5KxdSxnYY=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=eVf9/BNMPRjwczbM7iahY3o44VgMe7G/UVLOyCq9O4AKM0gdsKZR+VXOsS760euOJ vMB44qFn0brPW6gqWGPTjw/6Lgk90rcCgfz81kcghYhCQFhfBxSRWBtuDaTUfA40tF gh7qdg9O41aPMTtlUeUn3Ta4kEa9hzgHGEtUT3NMRG1jc2lguTHIMRMbm2fKdzQRuL Ej+IRDkOrj+UHqNKm9xoxOEqPu9zsCFayIXApk5VKz8m8g84rvju00m46+rUNtgVSa u4Q/E5Z6FaNp4KlDTPI9+UBjKUQXeMsDnd9JrtIrfvwwPRvVOzfmV7r1PNLtRvsAhG pJUt0RyibbEYA== Original-Received: from alfajor (unknown [216.154.41.47]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 79F08120490; Fri, 19 Feb 2021 15:11:54 -0500 (EST) In-Reply-To: (Pip Cet's message of "Fri, 19 Feb 2021 19:04:34 +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 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:265284 Archived-At: >> > (f a b c &rest d) >> > rather than >> > (apply #'f a b c d) >> I don't think it's sufficiently nicer to justify making such a change, > > I think "usage mimics declaration" is a very important concept, I generally agree and the above syntax is indeed satisfactory from that point of view (and funnily enough Scheme's neat (lambda (x . y) body) syntax (which is arguably inspired by a similar desire) does not enjoy such a nice equivalent at call sites since (f x . (append a b)) can't be distinguished from (f x append a . b)). > but if we're making sunk-cost arguments, one could argue against > fairly much any change... One can argue against any change, indeed (as demonstrated daily on this list ;-), so in the end it's always a judgment call on the overall tradeoff. >> OTOH, the nice thing about `apply` is that it's just a function: no >> special treatment, no new syntax, nothing. Try `grep apply >> lisp/emacs-lisp/bytecomp.el` and see how it really needs no >> special treatment. > ...but it gets that special treatment, which is why (apply #'or) is > mis-compiled. Actually, it's not the compiler, it's the optimizer. [ Yes, it's a nitpick, but nevertheless... Also, I'm not completely sure in which sense it "miscompiles" it, since it can't be compiled correctly, AFAIK. ] >> I'd rather reduce the use of `&rest` and `apply` than try to make it >> more sexy, since it's fundamentally quite inefficient > I think the inefficiency is fundamental to "apply", not to "&rest". > When you call a known procedure all the packing and unpacking of > arguments can be inlined... IMO it's more fundamental to `&rest` because the callee can rely on the `&rest` list being a fresh new list (it can safely perform destructive update on it). > I think we're back to a fundamental question here: if I understand > correctly, to you, an ELisp function is fundamentally of the "take a > list, return a Lisp object or throw" type, as though it were defined > like this: > > (defan f args (if (/= (length args) 2) (throw > 'wrong-number-of-arguments)) (+ (car args) (cadr args))) Indeed. > In your world, (lambda (&rest args) (apply #'f args)) is the same as > f. In my world, we have "func-arity", to which it isn't. In my view, a function value of the form (closure ...) or (lambda ...) or #[...] has arity, but a function value represented by a SYMBOL does not because it can change at any time. Stefan