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: Pattern matching on match-string groups #elisp #question Date: Sun, 28 Feb 2021 10:37:25 -0500 Message-ID: References: <87v9agxkld.fsf@tcd.ie> <80CE2366-76F4-4548-B956-F16DFCE23E4C@acm.org> <258C930A-B183-4211-9917-0AD96C17A638@acm.org> <288FFC66-E3BE-4E5F-AAD5-309A632F8058@acm.org> <62A88DEE-5BFD-4479-AB15-1A43DC2B299D@acm.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="22613"; 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" , Ag Ibragimov , Emacs developers To: Mattias =?windows-1252?Q?Engdeg=E5rd?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Feb 28 19:07:04 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 1lGQTA-0005nB-1P for ged-emacs-devel@m.gmane-mx.org; Sun, 28 Feb 2021 19:07:04 +0100 Original-Received: from localhost ([::1]:55180 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lGQT8-0002bm-UO for ged-emacs-devel@m.gmane-mx.org; Sun, 28 Feb 2021 13:07:02 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46890) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lGQSQ-00029l-3Z for emacs-devel@gnu.org; Sun, 28 Feb 2021 13:06:20 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:34395) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lGQSN-0001Z0-W5 for emacs-devel@gnu.org; Sun, 28 Feb 2021 13:06:17 -0500 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id D4694100236; Sun, 28 Feb 2021 10:37:27 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 4CD0E1000F4; Sun, 28 Feb 2021 10:37:26 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1614526646; bh=mkAzUDOKh7s41nTGzHvCa18T2Pa2GZ2El4W7b/DlJ8U=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=hR3JtRqN3cF4rJRRrZef6opsl/J7b/s5LBTi5gz7qsdy/9on6V7LtxcUebXzPUrJd 2dtzucpOPnOtLdfWsGPpfyhA6/4wtmR83W5LgmhnxGUpdP9RTnKbuHQaeOlg7zM5RB WTNBszDmVm2YqtBeWvLElctyiLWeombk2i/VApwNmLziEMuQKzMgvDLb0jMBgBAEML NYJ+Htm4sEdl0BqwQ60TkEwjXnJkACWc6O9wC1Dnd4smedhf1IvZppK0J8UPgUEBrd j/rljmbeL5Pi/lt077UUdvYgtkTAHeSVVt4dnipuRqCTae7eVfQ6VhPg7gqBvrxEab ymp/hGL5HD5kw== Original-Received: from alfajor (unknown [216.154.41.47]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 0AF6112017E; Sun, 28 Feb 2021 10:37:25 -0500 (EST) In-Reply-To: <62A88DEE-5BFD-4479-AB15-1A43DC2B299D@acm.org> ("Mattias =?windows-1252?Q?Engdeg=E5rd=22's?= message of "Sun, 28 Feb 2021 14:46:42 +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:265755 Archived-At: > I went with dotted lists (a b c . d) because benchmarking showed it to be > faster than either proper lists or vectors, the generated code is smaller > than for lists, and the case of a single variable reduces naturally to no > consing at all. Nice. > Looking a bit closer it gets more nuanced: one reason why > > (pcase (list 1 2 3) (`(,a ,b ,c) (+ a b c))) > > is faster than > > (pcase (vector 1 2 3) (`[,a ,b ,c] (+ a b c))) > > is that the latter contains three general function calls: to `vector`, > `vectorp`, and `eql` (for checking the length), whereas the list version has > byte-ops for everything. Very good point. The choice of which primitives deserve their own bytecode was made many many years ago and it likely deserves a serious reconsideration [ we still have dedicated byte codes for Btemp_output_buffer_show and Btemp_output_buffer_setup ;-( ] Personally, I'd vote to start by making the `eq` byte code return the value of `Feql` ;-) Stefan