emacs-devel
[Top][All Lists]
Advanced

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

Re: "Raw" string literals for elisp


From: Adam Porter
Subject: Re: "Raw" string literals for elisp
Date: Wed, 08 Sep 2021 06:34:44 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)

This would be an exciting feature to have in Elisp.  Thanks for working
on it.

If I may make a somewhat bold, and hopefully not too bikesheddy
suggestion (and one that's probably been made before, when this topic
has come up): Rather than having double-quote characters requiring
escaping in raw strings, would it be possible to do something slightly
Perlescent (I know) and allow the delimiters to be specified?  That
would make them much more useful.  For example, maybe something like:

  #r"foo bar baz"  ;; => "foo bar baz"
  #r|foo "bar" baz|  ;; => "foo \"bar\" baz"

For extra bonus points, it would be nice if leading indentation at the
beginning of a line in a raw string were omitted, similar to Python's
triple-quoted strings.  That would allow docstrings to look something
like:

  (defun foo (arg &optional bar)
    #r|Frobnicate ARG.
       If BAR, require ARG to be "baz".|
    (if (and bar (equal arg "baz"))
        (frobnicate arg)
      (frobnicate arg)))

The delimiter could even be repeated, like:

  #r"""
    foo
    "bar"
    baz
    """
    ;; => "foo\n\"bar\"\nbaz"

Though perhaps I'm getting too far ahead.  :)




reply via email to

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