[Top][All Lists]

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

Re: regular expressions that match nothing

From: Alan Mackenzie
Subject: Re: regular expressions that match nothing
Date: Fri, 17 May 2019 09:43:01 +0000
User-agent: Mutt/1.10.1 (2018-07-13)

Hello, Phil.

On Fri, May 17, 2019 at 11:18:49 +1200, Phil Sainty wrote:
> > 15 maj 2019 kl. 21.41 skrev Alan Mackenzie <address@hidden>:
> >> I think regexp-unmatchable is too much of a mouthful.

> I like it, myself.  I think the meaning is 100% clear and unambiguous
> for the reader (which I can't say about the alternative suggestions
> that I've seen).

I find it too difficult to read.  My brain simply doesn't recognise it
instantly, the way it would re-nomatch.  At the moment, given there is
no similar symbol name in Emacs, this is less urgent, but if more
similar long symbols were introduced this would be a pain - a minor pain
yes, but a pain nevertheless.

> Are we expecting this to be used so much that we're prioritising
> brevity over clarity?

Brevity is clarity - up to a point.  We write `defun', not
`define-function'.  Who would argue that the latter of these is clearer?

Why has nobody commented on my suggestion of using re- rather than
regexp- as the prefix?  We already have re-search-forward.

> (That's a genuine question -- I have a similar definition in my own
> config, and I have exactly one use for it.)

There are quite a few uses of "a\\`" in CC Mode.  If they were to be
replaced by regexp-unmatchable, I might have to re-flow the code, to
avoid it going too far over 80 columns.

> On 2019-05-16 22:54, Mattias Engdegård wrote:
> > 4. The point of this name isn't to be shorter than the regexp string
> >    it represents, but to be more readable and avoid mistakes and
> >    substandard reinventions.

> Quite.

> > 2. (rx (or)) is even shorter than re-nomatch, and is very memorable.
> >    (rx (|)) is shorter still.

This is undesirable in source files which don't otherwise use rx.  It's
also cryptic, forcing some readers to do research.

> I don't think those are much better than people using "a\\`".

> *Surely* `rx` can simply acquire a symbol for this?

> (rx unmatchable) or similar?

> -Phil

Alan Mackenzie (Nuremberg, Germany).

reply via email to

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