unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Improving aesthetics & readability of backquote
@ 2019-05-20  3:03 Paul W. Rankin
  2019-05-20  3:38 ` Stefan Monnier
                   ` (3 more replies)
  0 siblings, 4 replies; 29+ messages in thread
From: Paul W. Rankin @ 2019-05-20  3:03 UTC (permalink / raw)
  To: emacs-devel

wrt. 
http://lists.gnu.org/archive/html/help-gnu-emacs/2019-05/msg00022.html

I understand that aesthetics and readability are not going to be a 
concern for many, but I'd like to put forth this suggestion 
anyway.

For as long as I've used Emacs Lisp, I've found the backquote[1] 
to be ugly and unreadable, to the extent that I've gone to lengths 
to avoid using it. It looks like a mistaken quote added by someone 
using an unfamiliar keyboard. Then when you add the splice... 
ugh..

    (setq a '(3 4))
    (setq b '(6 7))

    `(1 2 ,a 5 ,@b 8)
    -> (1 2 (3 4) 5 6 7 8)

I know people make fun of Perl for being "line noise"[2] and IMO 
the backquote approaches that.

Add to this the \` is just an alias for backquote, which doesn't 
imply any meaning except as relation to itself. Its meaning cannot 
be inferred through the code alone.

I suggest that we could introduce some aliases and augment the 
reader constucts a little to make them more aesthetically pleasing 
and more readable.

The easy first step would be chosing a nice and meaningful alias 
for backquote. Considering the semantic role of backquote seems to 
be both to "quote" and selectively "eval" its body form, and 
together with the tradition of Emacs Lisp making contractions from 
e.g. "define" + "function" -> "defun", then I suggest:

    (quoteval ...)

Which sits similarly to:

    (quote ...)
    (eval ...)

Then it would be a case of augmenting the "unquote" ,VAR and 
"splice" ,@VAR reader constructs:

    (quoteval (1 2 (unquote a) 5 (splice b) 8 ))
    -> (1 2 (3 4) 5 6 7 8)

(Both "insert" and "unquote" are used in backquote.el; I lean 
towards "unquote" because there is already the function "insert".)

Although the above is more verbose, to me this is immediately 
clear what's happening in the code, and is much more aesthetically 
pleasing.

If it remains unclear, my suggestion is not to supplant the 
original syntax; I position this suggestion in a similar vein as 
the rx library.

Thoughts?

[1]: (info "(elisp) Backquote")
[2]: https://famicol.in/sigbovik/


-- 
https://www.paulwrankin.com



^ permalink raw reply	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2019-05-22 22:40 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-20  3:03 Improving aesthetics & readability of backquote Paul W. Rankin
2019-05-20  3:38 ` Stefan Monnier
2019-05-22 15:44   ` Stefan Monnier
2019-05-20  8:52 ` Alan Mackenzie
2019-05-20 13:25   ` Paul W. Rankin
2019-05-20 14:02     ` Alan Mackenzie
2019-05-20 14:26       ` Paul W. Rankin
2019-05-20 16:08         ` Ken Olum
2019-05-20 23:19   ` Richard Stallman
2019-05-21  2:06     ` Paul W. Rankin
2019-05-21  2:22       ` Noam Postavsky
2019-05-21  2:39         ` Paul W. Rankin
2019-05-21 20:19       ` Richard Stallman
2019-05-22  2:46         ` Paul W. Rankin
2019-05-22  7:56           ` Eli Zaretskii
2019-05-22  8:55             ` Paul W. Rankin
2019-05-22 15:57               ` Michael Heerdegen
2019-05-22 16:13                 ` 조성빈
2019-05-22 16:13               ` Michael Heerdegen
2019-05-22 22:40               ` Richard Stallman
2019-05-20  8:59 ` Lars Ingebrigtsen
2019-05-20 13:35   ` Paul W. Rankin
2019-05-20 13:47     ` Basil L. Contovounesios
2019-05-20 14:18       ` Paul W. Rankin
2019-05-20 14:48         ` Basil L. Contovounesios
2019-05-20 15:25     ` Lars Ingebrigtsen
2019-05-20 23:21       ` Richard Stallman
2019-05-21  2:34         ` Paul W. Rankin
2019-05-22 16:14 ` Sam Steingold

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).