bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#61281: Double backquote expansion and ", " (was: bug#61281: “`(a \,


From: Ihor Radchenko
Subject: bug#61281: Double backquote expansion and ", " (was: bug#61281: “`(a \, b)” equals to “`(a . , b)”)
Date: Tue, 07 Feb 2023 11:50:47 +0000

Michael Heerdegen <michael_heerdegen@web.de> writes:

> But this has not directly a relation to what we discuss here.  If you
> rewrite ,X as (\, X) you have additional ways to express the above
> things, looking like (,'\, X) etc (though these are less readable).

I may indeed be misunderstanding the case I raised vs. the discussed bug.
Let's branch this off.

> Ihor Radchenko <yantar92@posteo.net> writes:
>
>> I recall one user had a need to macro-expand something that indented to
>> be passed to another macro-expand. We did not find a way to retain ","
>> in the macro-expanded sexp.
>
> I guess you are describing the common difficulties related to multiple
> levels of backquotes (nested backquotes).  These are tricky (for human
> brains) and you need to know little "tricks" to get what you want (took
> me a while to discover how to deal with nested backquotes, maybe we
> should have examples in the manual?).

I would appreciate having such examples in the manual.
Also, CCing Adam, who originally raised the question.

> Anyway, you (only) need to use trivial quoting, it is not necessary and
> probably not good style to use the symbol "," instead of the reader
> construct in human written code.

Could you elaborate?

> Compare:
>
> #+begin_src emacs-lisp
> ;; Substitution at the same place at multiple levels:
> (let ((f 'my-function))
>   ``(when (funcall ,,f) (do-something)))
> ==>
>  `(when (funcall ,my-function)
>     (do-something))
>
> ;; Substitution once, by outside level backquote:
> (let ((f 'my-function))
>   ``(when (funcall ,',f) (do-something)))
> ==>
>  `(when (funcall ,'my-function)
>     (do-something))
>
> ;; Substitution once, by the inside backquote
> ``(when (funcall ,,'f) (do-something))
> ==>
>   `(when (funcall ,f)
>      (do-something))
>
>   or simpler:
>
> ``(when (funcall ,f) (do-something))
> ==>
>   `(when (funcall ,f)
>      (do-something))
> #+end_src
>
> You probably tried to get some of these cases work, and it's not trivial
> to get to a solution the first time one encounters this problem.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>





reply via email to

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