Skip to content
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

gensym vars now use X__gensymY instead of X`gensymY #19636

Closed
wants to merge 7 commits into from

Conversation

ringabout
Copy link
Member

@ringabout ringabout commented Mar 22, 2022

close #17304

@juancarlospaco
Copy link
Collaborator

Why not _generated_symbol instead of gensym ?. 🤔

@Araq
Copy link
Member

Araq commented Mar 23, 2022

Why not _generated_symbol instead of gensym ?

Because it affects the size of the generated C code and compile-times are never fast enough.

@ringabout
Copy link
Member Author

ringabout commented Mar 23, 2022

It seems that https://github.com/iffy/nim-argparse is broken because it uses the internal implementation of gensym:

  if "`gensym" in node.strVal:
    return ident(node.strVal.split("`")[0])

ref https://github.com/iffy/nim-argparse/blob/4048a76b24919807b0871dd145ba93a48c2688e7/src/argparse/macrohelp.nim#L35

@ringabout
Copy link
Member Author

Should I use optNimV16Emulation or define nimOldGenSym to keep backward compatibility?

@Araq
Copy link
Member

Araq commented Mar 23, 2022

Looking at the patch I don't like the solution anymore. We need to find a better way.

Comment on lines +197 to +208
var isGenSym = false
while alen > 1:
if a[alen] == '_':
if a[alen-1] == '_':
dec alen
isGenSym = true
break
else:
dec(alen, 2)
else:
dec alen
if not isGenSym: alen = a.len
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something like this should work too

  let alen = rfind(a, "__")
  if alen < 0:
    alen = a.len

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants