-
-
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
Get symbol kind #7491
Get symbol kind #7491
Conversation
Something I would like to discuss here is the usefulness of the proc symbol=(n: NimNode; val: NimSym)
proc `$`(s: NimSym): string
proc `==`(a, b: NimSym): bool
proc getImpl(s: NimSym): NimNode
# and with this PR also this one
proc kind(s: NimSym): NimSymKind
let impl = n.symbol.getImpl
let kind = n.symbol.kind
# would become
let impl = n.getImpl
let kind = n.symKind |
Yeah, we should do without, I agree, good points! |
Should I implement proc symbol(n: NimNode): NimSym
proc symbol=(n: NimNode; val: NimSym)
proc `$`(s: NimSym): string
proc `==`(a, b: NimSym): bool
proc getImpl(s: NimSym): NimNode |
Yes. |
There is one thing I would like to discuss here, too. The NimIdent # NimIdent result
proc toNimIdent*(s: string): NimIdent
proc ident*(n: NimNode): NimIdent
# NimIdent argument
proc `!`*(s: string): NimIdent
proc `$`*(i: NimIdent): string
proc `==`*(a, b: NimIdent): bool
proc `ident=`*(n: NimNode, val: NimIdent)
proc newIdentNode*(i: NimIdent): NimNode
proc newCall*(theProc: NimIdent, args: varargs[NimNode]): NimNode
proc nestList*(theProc: NimIdent, x: NimNode): NimNode The only function that doesn't work with a NimNode is I think the best road to deprecate |
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.
Just some small comments. Looks good.
lib/core/macros.nim
Outdated
proc ident*(n: NimNode): NimIdent {.magic: "NIdent", noSideEffect.} | ||
|
||
proc symbol*(n: NimNode): NimSym {.magic: "NSymbol", noSideEffect, deprecated.} |
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.
Please add a doc comment with the usual deprecation template.
lib/core/macros.nim
Outdated
proc symName*(n: NimNode): string = | ||
$n.symbol | ||
proc getImpl*(symbol: NimNode): NimNode = | ||
symbol.symbol.getImpl |
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 these definitions really necessary?
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.
yes they are, otherwise bootstrapping breaks.
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.
I see.
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.
well at least when the bootstrapping compiler is updated, the when statement with the else branch can completely disappear.
Looks excellent, needs a changelog entry and more documentation overall. Also check if the existing documentation is outdated with this change. |
using |
It's really nice. I have nothing to complain. Not merging though since you had some questions in IRC. |
fixes #7366
when n is of type
NimNode
, then you can do the following:let symKind = n.symbol.kind