unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Michael Heerdegen <michael_heerdegen@web.de>
To: Alex <agrambot@gmail.com>
Cc: 27177@debbugs.gnu.org, npostavs@users.sourceforge.net
Subject: bug#27177: 26.0.50: Macroexpanding cl-loop and friends (make-symbol usage)
Date: Fri, 02 Jun 2017 05:27:16 +0200	[thread overview]
Message-ID: <87inkfrrvv.fsf@drachen> (raw)
In-Reply-To: <87lgpc79e1.fsf@gmail.com> (Alex's message of "Wed, 31 May 2017 20:02:30 -0600")

Alex <agrambot@gmail.com> writes:

> That's much better, though I still think it could/should be better. For
> example, if you have multiple uninterned symbols with different
> symbol-names, they're all referenced by #number, and use the same
> counter.
>
> It also seems to make the output uglier as well. Consider:
>
> (macroexpand '(cl-loop for x in '(1 2 3)
>                        for y in '(a b c)
>                        repeat 10
>                        repeat 20
>                        collect (list x y)))
>
> Note the expressions using #5#. I suppose the 0 is being shared.

Yes, or at least, a cons containing the 0.  That's how things look like
with print-circle enabled.

> It would also be nice if instead of many --cl-var-- variables,
> particular clauses would result in different symbol-names. For instance,
> if the `repeat' clause made a symbol called --cl-repeat--. This would
> further help readability.

I'm not sure if that is doable without rewriting the implementation,
since the macro expansion is automatically written code.

> Also, using gensym could help 3rd-party packages. I usually use
> macrostep to expand macros and the value of print-circle has no effect
> on its expansions. macrostep individually prints out each uninterned
> symbol using prin1; can this approach be easily modified to get the same
> result as macroexpand?

AFAICT `print-circle' and `print-gensym' also control how `prin1'
prints.


Note that when we changed the code to use `cl-gensym', we would not have
a really clean solution for the readability problem: if you print with
p-gensym and p-circle on, it would not look much different than now.  If
you print with those flags off, you (still) print to different (not
equivalent) code: when you read (evaluate) it, all uninterned symbols
would be replaced with interned symbols.  Though, with numbered symbol
names, you will be probably be lucky in most cases that the difference
doesn't matter.

But I see your point: the readability is a real problem.  Maybe we could
instead improve how things are printed?  Unfortunately that lies beyond
my knowledge.


> PS: The first line of the documentation of print-circle only mentions
> that it affects recursive structures. Perhaps it should mention the
> "shared substructures" part in the first line for emphasis?

I agree but somewhat hesitate because of the variable's name, which is
even more a source of confusion.


Michael.





  reply	other threads:[~2017-06-02  3:27 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-31 23:23 bug#27177: 26.0.50: Macroexpanding cl-loop and friends (make-symbol usage) Alex
2017-05-31 23:51 ` Michael Heerdegen
2017-06-01  0:29   ` Alex
2017-06-01  0:52     ` npostavs
2017-06-01  1:01     ` Michael Heerdegen
2017-06-01  2:02       ` Alex
2017-06-02  3:27         ` Michael Heerdegen [this message]
2017-06-02  4:42           ` Alex
2017-06-02 23:09             ` Michael Heerdegen
2017-06-02 23:17             ` npostavs
2017-06-02 23:46               ` Alex
2017-06-03  2:33             ` Stefan Monnier
2017-06-04  0:24               ` Alex
2017-06-06  4:20                 ` Stefan Monnier
2017-06-06 20:31                   ` Alex
2020-08-24 14:53               ` Lars Ingebrigtsen
2017-06-01  0:29   ` npostavs

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=87inkfrrvv.fsf@drachen \
    --to=michael_heerdegen@web.de \
    --cc=27177@debbugs.gnu.org \
    --cc=agrambot@gmail.com \
    --cc=npostavs@users.sourceforge.net \
    /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).