From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.devel Subject: Re: thunk.el: Document that thunk-force == funcall? Date: Fri, 27 Nov 2020 18:22:38 +0100 Message-ID: <87im9qhfz5.fsf@web.de> References: <871rgs3tdx.fsf@web.de> <87v9dtttbr.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="30581"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Nicolas Petton , Emacs Development To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Nov 27 18:23:59 2020 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 1kihTS-0007pH-Fl for ged-emacs-devel@m.gmane-mx.org; Fri, 27 Nov 2020 18:23:58 +0100 Original-Received: from localhost ([::1]:45402 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kihTR-000106-Gu for ged-emacs-devel@m.gmane-mx.org; Fri, 27 Nov 2020 12:23:57 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49236) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kihSN-0000Mk-5s for emacs-devel@gnu.org; Fri, 27 Nov 2020 12:22:51 -0500 Original-Received: from mout.web.de ([217.72.192.78]:34977) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kihSL-0002c9-9S for emacs-devel@gnu.org; Fri, 27 Nov 2020 12:22:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1606497759; bh=di/OUibyvTGoCS0y0ta88iGSDEwpRZ62aCWYm8W1vuY=; h=X-UI-Sender-Class:From:To:Cc:Subject:References:Date:In-Reply-To; b=pkDssgYSpCiiStjBFrqBG9m17P8Yvu13gyXZuGUDgqBnSiim0nEbYToenFoqzNZDM Q4lAv5I7C3XrkA7b+MochAWbHDjFZCcMNymSVjUXAsytgwh6q4zLPKghYEyuE/YbQP 1ZX0mBWklBZkGxGFZpym2VInrsvg8tfecUxu5hsg= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Original-Received: from drachen.dragon ([94.218.219.247]) by smtp.web.de (mrweb103 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MSrgv-1kakp82zMj-00RrvT; Fri, 27 Nov 2020 18:22:39 +0100 In-Reply-To: <87v9dtttbr.fsf@web.de> (Michael Heerdegen's message of "Wed, 25 Nov 2020 15:16:40 +0100") X-Provags-ID: V03:K1:k+UnLGBDHQkdQMdis/NfASsg36PlKnJ5lJi3m1djKRIcGy2noVb fklThAoQhTrL+y/Cag9648CT0lj3Z2gtM1CunqnLSKek8HfVVl7sZaZTpv9u9EmTjY67pQj BKc5L3+66zg3Ih0uab+zk9fsJOhlrbJzFngR+T37hTHjFefBJRekpAGwMb7yuwMIkZAyxVA YEPh+Hz1sWlKbfQRHEw1Q== X-UI-Out-Filterresults: notjunk:1;V03:K0:2Fmwp6TjUoU=:IwdmTx8GeH7FUv5QC/GXHk XHFs9ROFxjFjjg074/krbf3nyYMsQEZlLxLQAaQhjsE1k9GzVx13UvkpuzkikdK6Fh5bpqemf 9+81s8sKyeOfE66qxFpyku2Dh+Sb6/awQzUwfs6UjlNwuyWsaNLe4TTr6ZCvf/ksp+p5UfgpN C99M1vZe3KMGdCxkZugjWYjCZmXlkfvT75zHD0/qzzWoKHGViqflBlHq34cNdWKaFfYOoZkln DthP55SEOZOBsCxngesFgUKFzdB7EGrhsrs/lnLLSqJkj+cP9bBYQLjEjp5RKJhZrLHlxWcvQ 9k/+ULJGvKQvKunL7CE6xzl5/aJpaA7cc1eTb1NUrA9Fom4gezxgo4vpdnj833KntvCCNBw1T 5U5DoX41r6a5OgVbXFN6Dw4po/MQ2Is7Y3vhIhLZJwDDrSnkdqWigQsx4N7VHf57hg7/fHmiP v6vLxHdQv2OSwNhr1CVUAFr0gf7Hm/4Tf5whV6Q0sbcgTUtgTGkxFsEgO52JmBlNsjdw49Dw/ 0sIpB+KdqI6IOAKYTud730XP1qfTO996STLKW7stKUT++3sDjZH3I42pyEYdRPtQNxlWtf1cj 9xzdkBhOrR4wqqO1nEcP9SDPEwC4cptTpIEeLWJQdv7AXhlwm5a/w3Is1LLlYLkpQIhMb2jmR tM1aaLxq+tHC2pZVfp/fJyJvoTjZ/glkZgJZlb7CBKUlZgcPCZWkZxtSm0KnVleJ2uQpL8FZg AOinGvJVZQ1fINuT2jqQIfVl1Mok6YavtGkaxaMG3Hpijt7q7K8h1g/ye30bgBF0R3eTlJ5a Received-SPF: pass client-ip=217.72.192.78; envelope-from=michael_heerdegen@web.de; helo=mout.web.de X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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:259911 Archived-At: Michael Heerdegen writes: > I don't have any concrete real-life examples. [...] Actually I have one real-life example: #+begin_src emacs-lisp (defun el-search--change-p (posn revision) ;; Non-nil when sexp after POSN is part of a change (if (buffer-modified-p) (if (eq this-command 'el-search-pattern) (user-error "Buffer is modified - please save") nil) (save-restriction (widen) (let ((changes (el-search--changes-from-diff-hl revision)) (sexp-end (el-search--end-of-sexp posn)) (atomic? (thunk-delay (el-search--atomic-p (save-excursion (goto-char posn) (el-search-read (current-buffer))))))) (while (and changes (or (< (cdar changes) posn) (and ;; a string spanning multiple lines is a change even when not all ;; lines are changed (< (cdar changes) sexp-end) (not (thunk-force atomic?))))) (pop changes)) (and changes (or (<= (caar changes) posn) (and (thunk-force atomic?) (<= (caar changes) sexp-end)))))))) #+end_src I can live with `thunk-force' here; being able to use it as a function would make the code a bit more readable. Although, hiding the function's nature as a thunk might not be good OTOH. A thunk or fbound function have the advantage that they can be passed without forcing. Contrary to symbols bound with `thunk-let'; a thunk passed to a function this way is forced before that function is called, even when the thunk's result is never used. That's why I'm wondering whether `thunk-let' is as cool as I had thought. Ok, anything else to say, apart from the empty string? Regards, Michael.