-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added freshidents to macros #16093
Added freshidents to macros #16093
Conversation
Please add a test for |
Looks good to me |
lib/core/macros.nim
Outdated
## This forces the compiler to perform a new lookup pass. | ||
case n.kind: | ||
of nnkSym: | ||
result = ident(n.repr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there some reasons using repr
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh yes, it should be $n
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As disruptek said on irc:
a symbol created with genSym needs to be rendered as
ident(repr sym)
in order to capture the unique name correctly.
So in the test I added ident($n)
or similar will output just "tmp" and redefinition error, whereas with repr
you get tmp14141
and works properly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK, with repr you can also get tmp`12312
for gensym which will not compile
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK, with repr you can also get
tmp`12312
for gensym which will not compile
test passes so it might be fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, tmp`12312
is fine to use as an identifier once past the parser
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe there's a more correct method than repr
, but I am personally fine with its use here.
This is a special case of what I called |
Done see link. But |
Bummer, why though? collect takes |
A couple of points:
|
If the end goal API is |
This pull request has been automatically marked as stale because it has not had recent activity. If you think it is still a valid PR, please rebase it on the latest devel; otherwise it will be closed. Thank you for your contributions. |
There are plenty re-implementations of this all around. It's good to have one in the stdlib.