Skip to content

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