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: Make regexp handling more regular Date: Thu, 03 Dec 2020 10:00:24 -0500 Message-ID: References: <87lfeg60iy.fsf@gnus.org> <87a6uv7vp1.fsf@mail.linkov.net> <87360nz3gl.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20730"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: emacs-devel@gnu.org, Juri Linkov To: Lars Ingebrigtsen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Dec 03 16:03:01 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 1kkq8K-0005EH-JK for ged-emacs-devel@m.gmane-mx.org; Thu, 03 Dec 2020 16:03:00 +0100 Original-Received: from localhost ([::1]:39198 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kkq8J-0004WN-L0 for ged-emacs-devel@m.gmane-mx.org; Thu, 03 Dec 2020 10:02:59 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45278) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kkq5w-0003av-AD for emacs-devel@gnu.org; Thu, 03 Dec 2020 10:00:32 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:58925) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kkq5t-0001O8-97 for emacs-devel@gnu.org; Thu, 03 Dec 2020 10:00:31 -0500 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 240BB100A09; Thu, 3 Dec 2020 10:00:28 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 7D2E1100384; Thu, 3 Dec 2020 10:00:26 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1607007626; bh=0aBv/6b62o9OOiyBlEIra4mNC7tHWsIqs+XvRXMLqX8=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=mer0g+nTReLqcEzRozloegLZTcwe2jRvHXgX/SXO80T2OnAFuXftzdjMffc+2QKC1 GNom07YbZU31ZENFDp81pDYu3tShf+DCefd8r3tFv79sxc0GqIR1wVFx0WT61Pd6un sbOaOfL4759Ezmrkm4B98NPhsg8Q7HYNB8X8kfhqT2JDGwD64P6Y3Jg2dJJ6iZdtpc VRnMPyoGaRk3rIRU516qfKuYwiTBsexqmbXPTGrcVaLeQbxlysBS9yiYDTPw1BdFBF i61nxA//3XwCxf1xuvwwoBr12Wn4JEMiNEqF/jQft0XlrLn2HhSYRqOwnFJr4HU95X VoxystoOuAE4A== Original-Received: from alfajor (69-165-136-52.dsl.teksavvy.com [69.165.136.52]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 199CD120169; Thu, 3 Dec 2020 10:00:26 -0500 (EST) In-Reply-To: <87360nz3gl.fsf@gnus.org> (Lars Ingebrigtsen's message of "Thu, 03 Dec 2020 09:41:30 +0100") 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:260220 Archived-At: >>> So my idle shower thought for the day is: Is there any reasonable path >>> forward that the Emacs Lisp language could take here? >> Currently the match data is like a dynamically bound variable accessible >> to the callee. But maybe the match data should be only lexically-bound? >> (This is just a vague idea, I don't know how to implement this.) > Yes, I wondered whether one could use some lexical magic here, but I > didn't quite see what that would look like. Actually, currently the match-data is *not* like a dynamically-scoped var, but like a global var. And we don't really need it to be lexically scoped, we would be already well-served with a dynamically-scoped var. E.g. we could have (with-re-match "regexp" ... (match-beginning 0) ...) where `with-re-match` could look like `(if re-match-data-in-use (save-match-data ,@body) (let ((re-match-data-in-use t)) ,@body)) so we'd save the match-data lazily. [ Tho, it would still save the match data more often than we currently do, of course. ] Stefan