From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Emacs regexp scan (Sep 29) Date: Sat, 05 Oct 2019 13:59:24 +0300 Message-ID: <83k19j4fw3.fsf@gnu.org> References: <1697CA97-B2E6-4202-B14D-99DCF93954FD@acm.org> <02405f0d-788f-1b87-0269-b06eb2d67ff8@cs.ucla.edu> <83zhif4nq6.fsf@gnu.org> <6cf4485e-3d94-ce92-6342-d83cdc7f95d7@cs.ucla.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="49666"; mail-complaints-to="usenet@blaine.gmane.org" Cc: mattiase@acm.org, emacs-devel@gnu.org To: Paul Eggert Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Oct 05 13:00:09 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iGhnE-000Clo-JN for ged-emacs-devel@m.gmane.org; Sat, 05 Oct 2019 13:00:08 +0200 Original-Received: from localhost ([::1]:55654 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iGhnD-0001qD-7f for ged-emacs-devel@m.gmane.org; Sat, 05 Oct 2019 07:00:07 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44338) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iGhmj-0001q2-1e for emacs-devel@gnu.org; Sat, 05 Oct 2019 06:59:38 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:37248) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1iGhmh-0004zd-Fu; Sat, 05 Oct 2019 06:59:35 -0400 Original-Received: from [176.228.60.248] (port=1345 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1iGhmg-00079T-9R; Sat, 05 Oct 2019 06:59:34 -0400 In-reply-to: <6cf4485e-3d94-ce92-6342-d83cdc7f95d7@cs.ucla.edu> (message from Paul Eggert on Sat, 5 Oct 2019 02:52:34 -0700) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] 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.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:240610 Archived-At: > Cc: mattiase@acm.org, emacs-devel@gnu.org > From: Paul Eggert > Date: Sat, 5 Oct 2019 02:52:34 -0700 > > On 10/5/19 1:10 AM, Eli Zaretskii wrote: > > both variants are valid, so it sounds like your personal stylistic > > preference is for the latter. Is that the only reason? > > No. The "Special Characters in Regular Expressions" subsubsection of the Elisp > manual recommends putting '-' at the end of bracket expressions, since putting > '-' elsewhere can cause confusion (one or two examples of which caused bugs that > was fixed in that patch). The patch did not systematically put "-" at the end of > every bracket expression, only those reasonably near bugs and other glitches. The text in the manual says: To include a ‘-’, write ‘-’ as the first or last character of the character alternative, or as the upper bound of a range. That's it. And I personally can see no confusion in the likes of "[-+]", whereas I did need to consult the manual to learn that "[+-]" is also right. So at least for me, the confusion worked the other way around. > > If the regexp scanner needs to be pacified, isn't it better to fix the > > scanner instead? > > No, as the regexp scanner was right here: it complained about unescaped literal > "+" in regexps, which is poor practice (and is documented as poor practice in > the Elisp manual). Poor, but correct. Look, this scanner is a good tool, but forcing a particular set of stylistic preferences on the project by using that tool, let alone silently so, is more than we have bid for. If you have strong enough opinions on that, let's discuss this first, document the agreements in the manual, and only apply them after that. > > the > > original code looks simpler to me than the new one, as the former is > > just a simple while loop, whereas the latter is a nested dolist. > > Actually the old code was so confusing that it was a bit hard to see that it was > a nested loop (not a simple while loop). I originally had the same confusion > that you did, which is why I redid the loops to make the nesting more obvious > and to lessen the number of lines of code. That's again a personal stylistic preference that I'd rather not regard as a reason strong enough to change correct code. If anything, it runs the risk of introducing bugs that can lie low years before they are detected. If you think the code might be incorrect, find an test case where it misbehaves, then modifying it will be justified. In general, I find that we make too many changes whose justification is weak at best and non-existent at worst. This both wastes our limited resources and risks introducing bugs for no good reason. Let's try to restrain ourselves and not make changes just because we can. Emacs is an old and stable program; we should try not to destabilize it unless we fix real bugs or introduce new features. Thanks.