-
-
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
add no-copy ast.getStrVal
for {nkIdent, nkSym, kStrLit..nkTripleStrLit}
#17540
add no-copy ast.getStrVal
for {nkIdent, nkSym, kStrLit..nkTripleStrLit}
#17540
Conversation
0e871db
to
8e33942
Compare
8e33942
to
1fae913
Compare
ast.getStrVal
for {nkIdent, nkSym, kStrLit..nkTripleStrLit}
ast.getStrVal
for {nkIdent, nkSym, kStrLit..nkTripleStrLit}ast.getStrVal
for {nkIdent, nkSym, kStrLit..nkTripleStrLit}
I don't see why we need to add this to ast, also introducing a global for it? |
it simplifies client code, as you can see in The global is harmless, it's just private symbol which simplifies client code and allows safe zero-copy access. |
I don't think it's worth it. The cases where you "need" a proc that gives you the strval regardless of wether it's a sym or and ident are rare (only two instances in renderer.nim). |
no there are many other cases, I just didn't want to do the changes in the same PR.
it'll also simplify cases like this for eg:
as well as debugging using accessors instead of raw field access is not something particularly surprising. |
I think I'll retract #17500 (comment) then, because the template is still much better than this approach.
You'd use |
the template causes a copy, whereas this PR doesn't.
different meaning, different semantics (eg for sym $ may show different results), both are useful; and |
The accessor could simply return the |
=> #17684
but there are plenty of existing, valid, cases in compiler where we do end up using the underlying string |
(migrated from #17500 (comment))
add a no-copy
getStrVal
; see discussion in #17500 (comment)