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: Some improvements for cl-flet Date: Sun, 12 Sep 2021 22:26:31 -0400 Message-ID: References: <87bl4zqnqn.fsf@gmail.com> <87czpe4rj2.fsf@web.de> <874kaqqxe7.fsf@gmail.com> <87y281cowz.fsf@web.de> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40806"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: akater , emacs-devel@gnu.org To: Michael Heerdegen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Sep 13 04:27:40 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 1mPbh6-000AO3-6I for ged-emacs-devel@m.gmane-mx.org; Mon, 13 Sep 2021 04:27:40 +0200 Original-Received: from localhost ([::1]:50000 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mPbh4-0005xi-1y for ged-emacs-devel@m.gmane-mx.org; Sun, 12 Sep 2021 22:27:38 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55666) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPbgD-0005HG-6k for emacs-devel@gnu.org; Sun, 12 Sep 2021 22:26:45 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:60755) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPbgA-0002Xt-Dv for emacs-devel@gnu.org; Sun, 12 Sep 2021 22:26:44 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 701FF802D4; Sun, 12 Sep 2021 22:26:46 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id F3BD480300; Sun, 12 Sep 2021 22:26:40 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1631500001; bh=mL6JwsXDpOwP+im0IL5fxqe4LaPrAhiX1UdzGg44FVs=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=fuWAxykCet3spxGAJqznjkOI2z2wRrK7vxHU8fFW0W7d+It4owzRPDbh72gV0/LXY 8HldJ19eadyUm7X7QWgMsB2uJ5k6whKU/hpeAt/qbcq/bQmdSuPo/FwMjGyHfkx/t+ HvDCSulpDvdKTcSoK/U8BGk4p1RMLiXkUBTAx/VjCQrre8YjD1NAMEtlwkKBfcTRNb WSBEMIRqRM1AU3P6XYfx0nN5yntmr7Lhwpvnj7+KNY+xlxg7IM7tRn5BjblKQP7seV ZhPbXC83W5f2MZGKMzuttKc4DHkqQv2PQd1VFsAnT2wdTIybT/G+LxfUHfESmpIsQH oQtOAGYp61ZPA== Original-Received: from milanesa (unknown [45.72.241.23]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id DEB20120296; Sun, 12 Sep 2021 22:26:33 -0400 (EDT) In-Reply-To: <87y281cowz.fsf@web.de> (Michael Heerdegen's message of "Mon, 13 Sep 2021 02:14:20 +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:274613 Archived-At: > (cl-flet ((multilinep (apply-partially #'string-match-p "\n"))) > (pcase something > ((and (pred stringp) (pred multilinep)) ...) > ...)) FWIW, this is better written as (cl-flet ((multilinep (s) (string-match-p "\n" s))) ...) which is both shorter and more efficient. But there are other cases where the "simple" form of `cl-flet` is more efficient and the CL version would need to be of the form (flet ((FOO (&rest args) (apply BAR args))) ...) or worse (let ((bar (BAR BAZ)) (flet ((FOO (&rest args) (apply bar args))) ...) which would introduce a significant inefficiency and which can be difficult for the compiler to optimize back to the efficiency of the code that our `cl-flet` gets without any effort. Its true that our `cl-flet` introduces an incompatibility with CL's semantics, but I considered that it's sufficiently minor that the tradeoff is worth it (as compared to introducing a separate new form). Stefan