unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Matthew Plant <maplant2@illinois.edu>
To: David Caldwell <david@porkrind.org>
Cc: "emacs-devel@gnu.org" <emacs-devel@gnu.org>
Subject: Re: Raw string literals in Emacs lisp.
Date: Sun, 27 Jul 2014 18:17:46 -0500	[thread overview]
Message-ID: <CAMbiG3-6e2wvOFpM8-LDjVbRkSqb4O24CQ6sfbCqSsF5yB6-EA@mail.gmail.com> (raw)
In-Reply-To: <53D567FD.4030708@porkrind.org>

[-- Attachment #1: Type: text/plain, Size: 2740 bytes --]

I think this is a very good idea. However, agreeing upon which semantics
are needed may prove problematic. Do you have any suggestions on this
point? The easiest method would probably just go off some other predefined
rules like perl's (but definitely not perl's).

-Matt

On Sunday, July 27, 2014, David Caldwell <david@porkrind.org> wrote:

> On 7/27/14 6:03 AM, David Kastrup wrote:
> > "Stephen J. Turnbull" <turnbull@sk.tsukuba.ac.jp <javascript:;>> writes:
> >
> >> Sure, you can do a lot for readability as PCRE or Python regexps have
> >> done, but regexps are unreadable almost by design, and those regexp
> >> syntaxes benefit from rawstrings, too.  Almost anything (that doesn't
> >> involve changing the meaning of existing legal programs) that improves
> >> readability of regexps is worthwhile.
> >>
> >> Rawstrings are cheap and effective.
> >
> > When rawstrings are supported, it becomes more expedient to recognize
> > things like \n and \t, probably also \f in regexps (\b is already
> > taken).  At the current point of time, they just evaluate to n and t.
> > That makes input of tabs and newlines in raw strings a nuisance and a
> > potential source of errors.
> >
> > It's not actually an issue with rawstrings as such, but rather of their
> > use within regexps.
>
> Why not, then, skip rawstrings completely and go directly to a regular
> expression reader: #r// (or even just #//) instead of #r""?
>
> Then you can add whatever semantics are needed for good regexp reading
> (ie, let '\n', '\t', and others get escaped in the string reading, but
> allow '\(' to go through unescaped). This will be just as easy to
> implement as raw strings.
>
> Languages like Javascript, Perl, Ruby, Bash, and Groovy have shown that
> having a special support for regexps at a language level is a very
> effective way of dealing with them. Plus it opens the door to
> extensions: #r//p for PCRE/Perl syntax[1] or #r//x for more readable
> regexps[2], etc.
>
> I think using rawstrings is too generic an answer to the problem. Given
> that so much of Emacs's functionality is reliant an regular expressions,
> it makes sense to design something specifically for them. Doing that
> means they can be tailored and tweaked for maximum functionality without
> worrying about possible other usages that people might come up (which
> will undoubtedly happen with rawstrings).
>
> -David
>
> [1] And practically every other language on the planet. Really, it seems
> like only Emacs is left in the dark ages of basic POSIX regexps where
> '(' means literal paren and not matching.
>
> [2] Another Perl feature, it allows whitespace and comments in regexps,
> for much improved readability. See http://perldoc.perl.org/perlre.html#/x
>
>

[-- Attachment #2: Type: text/html, Size: 3426 bytes --]

  reply	other threads:[~2014-07-27 23:17 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-25 19:47 Raw string literals in Emacs lisp Matthew Plant
2014-07-25 19:56 ` Tassilo Horn
2014-07-25 20:06   ` Matthew Plant
2014-07-25 20:15     ` Tassilo Horn
2014-07-25 20:24       ` Matthew Plant
2014-07-25 20:33 ` Tom Tromey
2014-07-25 21:40   ` Matthew Plant
2014-07-26  1:19 ` Stephen J. Turnbull
2014-07-26  5:28   ` Matthew Plant
2014-07-26  5:45     ` chad
2014-07-26 19:39       ` Matthew Plant
2014-07-27 12:27         ` Stephen J. Turnbull
2014-07-27 13:03           ` David Kastrup
2014-07-27 20:58             ` David Caldwell
2014-07-27 23:17               ` Matthew Plant [this message]
2014-07-28 18:27                 ` Richard Stallman
2014-07-28 19:32                   ` Matthew Plant
2014-07-29 19:15                     ` Richard Stallman
2014-07-30  0:26                       ` Matthew Plant
2014-07-30  4:28                         ` Richard Stallman
2014-07-30 18:54                           ` Matthew Plant
2014-07-28  2:16               ` Stephen J. Turnbull
2014-07-28  7:43                 ` Andreas Schwab
2014-07-30 20:28               ` Ted Zlatanov
2014-07-30 20:41                 ` David Caldwell
2014-07-30 20:54                   ` Ted Zlatanov
2014-07-30 21:01                     ` Matthew Plant
2014-07-30 21:16                       ` Ted Zlatanov
2014-07-30 21:19                         ` Matthew Plant
2014-07-31 10:13                           ` Ted Zlatanov
2014-08-02  8:47                     ` Alan Mackenzie
2014-08-02  9:14                       ` David Kastrup
2014-08-02 10:23                         ` Alan Mackenzie
2014-08-02 15:51                           ` Richard Stallman
2014-08-03  6:50                         ` Stephen J. Turnbull
2014-08-03  7:29                           ` David Kastrup
2014-08-03 13:12                             ` Stephen J. Turnbull
2014-08-03 13:27                               ` David Kastrup
2014-08-03 15:01                                 ` Stephen J. Turnbull
2014-08-04  1:55                                   ` Richard Stallman
2014-08-04  6:38                                     ` David Kastrup
2014-08-05  1:41                                       ` Richard Stallman
2014-08-05  6:15                                         ` David Kastrup
2014-08-03 13:40                               ` David Kastrup
2014-08-03 15:06                                 ` Stephen J. Turnbull
2014-08-04  1:55                           ` Richard Stallman
2014-08-02  9:17                     ` Andreas Schwab
2014-07-28  1:29             ` Stephen J. Turnbull
2014-07-26 21:37 ` Thorsten Jolitz
2014-07-29  6:32 ` William Xu
2014-07-29  7:40   ` Andreas Schwab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAMbiG3-6e2wvOFpM8-LDjVbRkSqb4O24CQ6sfbCqSsF5yB6-EA@mail.gmail.com \
    --to=maplant2@illinois.edu \
    --cc=david@porkrind.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).