From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Stephen J. Turnbull" Newsgroups: gmane.emacs.devel Subject: Re: Global match data considered harmful Date: Wed, 12 May 2010 11:01:10 +0900 Message-ID: <87ocglri8p.fsf@uwakimon.sk.tsukuba.ac.jp> References: <87y6frqje2.fsf@uwakimon.sk.tsukuba.ac.jp> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1273629798 25764 80.91.229.12 (12 May 2010 02:03:18 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 12 May 2010 02:03:18 +0000 (UTC) Cc: Juanma Barranquero , Lennart Borgman , Emacs-Devel devel To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed May 12 04:03:16 2010 connect(): No such file or directory Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OC1I4-0006Y5-0G for ged-emacs-devel@m.gmane.org; Wed, 12 May 2010 04:03:16 +0200 Original-Received: from localhost ([127.0.0.1]:33778 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OC1I3-0004aL-Gv for ged-emacs-devel@m.gmane.org; Tue, 11 May 2010 22:03:15 -0400 Original-Received: from [140.186.70.92] (port=35146 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OC1Hx-0004aF-53 for emacs-devel@gnu.org; Tue, 11 May 2010 22:03:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OC1Hu-0003wp-FZ for emacs-devel@gnu.org; Tue, 11 May 2010 22:03:08 -0400 Original-Received: from mtps02.sk.tsukuba.ac.jp ([130.158.97.224]:36689) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OC1Hu-0003wZ-7H for emacs-devel@gnu.org; Tue, 11 May 2010 22:03:06 -0400 Original-Received: from uwakimon.sk.tsukuba.ac.jp (uwakimon.sk.tsukuba.ac.jp [130.158.99.156]) by mtps02.sk.tsukuba.ac.jp (Postfix) with ESMTP id DB8A2820F; Wed, 12 May 2010 11:03:03 +0900 (JST) Original-Received: by uwakimon.sk.tsukuba.ac.jp (Postfix, from userid 1000) id 2F9AF1A3624; Wed, 12 May 2010 11:01:10 +0900 (JST) In-Reply-To: X-Mailer: VM 8.0.12-devo-585 under 21.5 (beta29) "garbanzo" a03421eb562b XEmacs Lucid (x86_64-unknown-linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:124712 Archived-At: Stefan Monnier writes: > >> The rule for where to place a save-match-data is: > >> around the code run between "looking-at" and "match-string-no-properties". > > *snort* I'm with Juanma. > > I'm not sure what that means. Most of the code I write is (ab)usable by .emacs; so I put save-match-data in the functions I write to protect naive callers from having their match-data tromped on by my using of matching code. If somebody complains about slow I defun a foo-internal without using save-match-data, and call that from foo. Why? I'm pretty sure there's at least one match-data-munching bug in XEmacs's minibuffer code at the moment (or it might be setcdr abuse), but I don't have time for a full audit and it's sufficiently intermittent that I don't have a strong incentive to do that anyway.... Missing save-match-data is about as hard to debug as missing GCPRO. :-( Better to put in too many than too few. > > This is just so wrong, you know. Not returning the match data, instead > > storing it in a global object, is arguably the worst design decision > > in all of Emacs. > > Preaching to the choir, eh? > [ Well "the worst" I don't know: it's not like there's a shortage of > global-abuse in Emacs. ] No shortage, for sure, but this one is like attaching an 'invisible property to a low-hanging rope in a narrow hallway.