emacs-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] Interpret #r"..." as a raw string


From: Daniel Brooks
Subject: Re: [PATCH] Interpret #r"..." as a raw string
Date: Tue, 02 Mar 2021 12:36:34 -0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> I have done a patch like that few years ago and it wasn't accepted
>> then see past discussion:
>> https://mail.gnu.org/archive/html/emacs-devel/2012-08/msg00071.html
>>
>> My notes and patch on implementing it:
>> http://diobla.info/blog-archive/raw-strings.html
>
> Thanks, that's quite helpful.
> At the end you state:
>
>     I personally think raw strings have their use outside of regexes and
>     would be a nice addition to the Emacs Lisp language.
>
> I'm willing to believe it, but so far the only concrete examples I've
> seen where raw string literals could be helpful are regexps.
>
> I'm clearly leaning against the addition of raw string literal (just
> like I'm leaning against the addition of multiline comments, BTW)
> because I feel the benefits are quite limited.

Luckily we have a readily–available corpus of elisp code that we can
measure.

The two–character sequence «\"» occurs on twelve and a half thousand
lines in just the Emacs lisp source code, often more than once per
line. 「\\」 is used on just over 27k lines, and “\\\\” 1604 times.

There are 101 lines using ⟦\\\\\\\\⟧.

     rg '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
    textmodes/reftex-vars.el
    564:      \"\\\\\\\\begin{eqnarray}\\\\|\\\\\\\\\\\\\\\\\" works for 
eqnarrays.
    
    net/tramp-sh.el
    962:    quoted=`echo \"$file\" | sed -e \"s/\\\"/\\\\\\\\\\\\\\\\\\\"/\"`

Look at that! 19 backslashes followed by a double–quote. That’s just
stupid. I wonder if it’s a record? Should we use git blame to find the
names of every person who touched that line and ask them what they
think? I can guess what they would say.

I think the benefits would add up pretty quickly.

db48x



reply via email to

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