[Top][All Lists]

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

Re: Raw strings (experimental patches inside)

From: Stephen J. Turnbull
Subject: Re: Raw strings (experimental patches inside)
Date: Fri, 10 Aug 2012 14:08:39 +0900

Vr Rm writes:

 > But the difficulty in using Emacs regular expressions shouldn't be
 > underestimated, especially for those of us on the dim side of the
 > superhuman spectrum.

Nothing personal, but if you can't even search for tabs (C-s C-q TAB
will do), of course you're going to find regexps difficult.  It's hard
to see how they can be simplified -- as used in all languages I know,
regexps are extremely compact notation.  Such notation is going to be
non-trivial if you can't remember to use C-q to insert command
characters literally, and I don't think raw strings are going to help.
(A sane assignment of character classes such that punctuation is
always an operator, as in Perl or Python, would be much more mnemonic
help, I think.)

You're going to have to appeal from a somewhat more proficient level;
Emacsen are designed to be used with a vocabulary of editing gestures
that is only about one order of magnitude smaller than the English

That said,

 > > That is not a problem significant enough to warrant the
 > > introduction of something like raw-strings.

Oh, come on, Stefan.  That's just elitism.

If insults won't persuade you, here are some real benefits.
raw-strings are a huge convenience when writing.[1]  They correspond to
the way you enter a regexp to isearch, and to the documentation.  They
are a big win for readability, both because of the greatly increased
S/N in long complex regexps, and because they reduce the number of
line-breaks needed for medium-complexity regexps in search functions
and the like.

The costs are about as small as they get.  Raw strings are extremely
easy to implement directly in the reader (OK, you'll probably
duplicate some of the code in regular string lexing, but really...),
if you use #r"" as XEmacsen do they can't break working code, and the
implementation is highly localized and therefore subject to
refactoring if later you decide to do it terms of a generic reader
macro rather than C code in the lexer.

And if that doesn't work, how about "S?XEmacs has them and Emacs
doesn't, nyaaah, nyaaah, nyaaah!"?

At least think one more time about it.  And maybe about a syntax for
PCRE regexps.  (Why a syntax?  Because wrapping them in a function is
more unnecessary verbosity, as would be duplicating all regexp-using
functions with pcre- versions.)

[1]  One could bind ?\\ to (lambda () (interactive) (insert "\\")),
but that would require a mode switch on entry and exit which is a
PITA itself, and not as visible to the author as a raw string syntax.

reply via email to

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