[Top][All Lists]

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

Re: :alnum: broken?

From: Paul Eggert
Subject: Re: :alnum: broken?
Date: Sun, 23 Feb 2020 10:13:16 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1

On 2/23/20 2:21 AM, Mattias Engdegård wrote:
GNU grep treats a bracket expression like '[:space:]' as an error, since it's 
inevitably a typo....
Such a check is obviously unsound, strictly speaking, which may be a reason for 
objecting to it.

I understand the objection, but the check is not unsound. The syntax of regexps was not carved in stone by God. It is something that we decide, and we can change our minds if the change would be an overall win, as it would be if Emacs behaved like Grep.

When the [[:alnum:]] syntax was added to regular expressions many years ago, it invalidated some astronomically-unlikely but formerly-valid expressions. For example, "[[:x:]" formerly was a valid regexp (with the same meaning as "[:[x]") but it is now invalid. So there is precedent for invalidating some astronomically-unlikely regexps when the overall change is a net benefit, as it would be if Emacs behaved like Grep.

The byte-compiler could warn about some of these blunders and if someone wants to change the byte-compiler to do that, it would be an improvement. However, this would necessarily either cry wolf or let blunders through, because the byte-compiler cannot reliably determine whether a string will be used as a regular expression.

reply via email to

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