-
-
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 compilesettings.nimVersionCT + friends #14648
Conversation
e714cae
to
ee26661
Compare
Why do you need this? |
to allow branching on compiler version (the branching directly on Branching is common is user code too, eg in ~/.config/nim/config.nims when you want to use a flag defined in x.y.z for nim versions recent enough to have it:
|
#[ | ||
A bit hacky but allows using this before most of system.nim is defined | ||
the only dependency is on NimMajor, NimMinor, NimPatch, `int` | ||
]# |
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.
Seriously?
Sorry but rejected. Nobody else asks for these stunts all the time. Please ask yourself why that is. |
@Araq well can you please re-open and I'll just remove everything except these 2 lines: # compilesettings.nim
proc nimVersionCTImpl(): (major: int, minor: int, patch: int) {.compileTime.} = discard
const nimVersionCT* = nimVersionCTImpl() plus the 2 lines in compiler/vmops.nim which is the part I really need. Thanks |
I'd rather keep the |
But it's right there in the name I'd be happy to revisit this PR to strip out everything except the part needed to get the CT tuple. |
It's not "confusing" but it is a choice and choices take up brain power. |
proc nimQuery(setting: Setting): RootObj {.magic.}
=> return a type that depends on the enum compilerdev#9compiler/condsyms
should rarely be needed since you can just do a version test (which self-document when something was added as side benefit)since
is a different thing since it looks at system.NimMajor+friends, which says nothing about the stdlib version nim was compiled at, so is suitable when branching for stdlib features, but not compiler featuresnimVersion
for symmetry, which is useful whensince
falls short, eg:when nimVersion >= (1,3,5): foo else: bar
, orwhen defined(js) and nimVersion >= (1,3,5): bar
etcexample
after that I'll resume #14068 (comment)
links
(EDIT)
https://github.com/nim-lang/Nim/pull/16406/files/e1b4468313399c0468c6675bf18a62c7e15b233c..f8d5208f2e377e2bd7c52ed8a96f18255c256850#r549607059