emacs-devel
[Top][All Lists]
Advanced

[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 11:10:09 +0300

> From: Paul Eggert <address@hidden>
> Date: Fri, 4 Oct 2019 14:42:41 -0700
> Cc: emacs-devel <address@hidden>
> 
> Thanks, I installed the attached patch, which I hope fixes all the bugs 
> and style glitches uncovered by that scan, along with some other style 
> glitches I noticed in the neighborhood.

I question the need for "fixing" those "style glitches" (and even the
very existence of a "style glitch", which sounds like a contradiction
of terms to me).

>  (defconst iso8601--year-match
> -  "\\([-+]\\)?\\([0-9][0-9][0-9][0-9]\\)")
> +  "\\([+-]\\)?\\([0-9][0-9][0-9][0-9]\\)")

What is the purpose of this and other similar changes?  AFAIK, both
variants are valid, so it sounds like your personal stylistic
preference is for the latter.  Is that the only reason?  If so, let's
please not make changes where this is the only reason, as doing so
risks breaking code (due to typos) and complicates forensics, and
otherwise serves no useful purpose.

>  (defconst tibetan-regexp
> -  (let ((l (list tibetan-precomposed-transcription-alist
> -              tibetan-consonant-transcription-alist
> -              tibetan-vowel-transcription-alist
> -              tibetan-modifier-transcription-alist
> -              tibetan-subjoined-transcription-alist))
> -     (separator "\\|")
> -     tail pattern)
> -    (while l
> -      (setq tail (car l) l (cdr l))
> -      (while tail
> -     (setq pattern (cons separator (cons (car (car tail)) pattern))
> -           tail (cdr tail))))
> -    (apply 'concat (nreverse (cdr pattern))))
> +  (let (pattern)
> +    (dolist (alist (list tibetan-precomposed-transcription-alist
> +                      tibetan-consonant-transcription-alist
> +                      tibetan-vowel-transcription-alist
> +                      tibetan-modifier-transcription-alist
> +                      tibetan-subjoined-transcription-alist)
> +                (apply #'concat (nreverse (cdr pattern))))
> +      (dolist (key-val alist)
> +     (setq pattern (cons "\\|" (cons (regexp-quote (car key-val))
> +                                     pattern))))))
>    "Regexp matching a Tibetan transcription of a composable Tibetan sequence.

This non-trivial change is documented as

    * lisp/language/tibetan.el (tibetan-regexp):
    Quote `+' in regexp to pacify the regexp scanner.  Simplify.

If the regexp scanner needs to be pacified, isn't it better to fix the
scanner instead?

I also don't think I see the simplification here.  In fact, 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.

Thanks.



reply via email to

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