[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Emacs regexp scan (Sep 29)

From: Eli Zaretskii
Subject: Re: Emacs regexp scan (Sep 29)
Date: Sat, 05 Oct 2019 13:59:24 +0300

> Cc: address@hidden, address@hidden
> From: Paul Eggert <address@hidden>
> 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

> > 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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]