-
Notifications
You must be signed in to change notification settings - Fork 23
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
namespaced defines: -d:myproj.mykey to avoid clashes #181
Comments
This was referenced Jan 21, 2020
Closed
This was referenced Oct 18, 2020
Closed
Seems to be accepted? |
metagn
added a commit
to metagn/Nim
that referenced
this issue
Jul 12, 2022
Araq
pushed a commit
to nim-lang/Nim
that referenced
this issue
Jul 12, 2022
* allow dots in defined() refs nim-lang/RFCs#181 * mention accents in older versions
FedericoCeratto
pushed a commit
to FedericoCeratto/Nim
that referenced
this issue
Jul 30, 2022
* allow dots in defined() refs nim-lang/RFCs#181 * mention accents in older versions
capocasa
pushed a commit
to capocasa/Nim
that referenced
this issue
Mar 31, 2023
* allow dots in defined() refs nim-lang/RFCs#181 * mention accents in older versions
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
defines
have global scope and can cause clashes.nim itself defines 363 unique defines, many of which are not prefixed by
nim
, see the list here: https://gist.github.com/timotheecour/8b2286478083a6068731a63114ee9dd0The current scheme (which is rarely followed) is to prefix by nimble package name, eg:
-d:nimHasLibFFI
However this scheme is brittle because of style and case insensitivity of defines, so you can still have clashes, eg:
-d:fooBarBaz # could be interpreted as (package foo, var barBaz) or (package fooBar, var baz) or any other variation
This is a problem because many nimble packages are prefixes of each other, eg see https://gist.github.com/timotheecour/182fce669ff217c6b0bc87d918303c3e which shows 233 (package1, package2) pairs such that package1 is a prefix of package2.
Furthermore, plenty of packages start with
nim
so that further causes chances of define clashes.There is a simple solution to that:
proposal
allow using a namespace for defines, eg:
nim c -d:myproj.mykey1 main.nim
nim c -d:myproj.mykey2:foo main.nim
we can just restrict (for simplicity) to at most a single dot, so that foo.bar is valid but not foo.bar.baz
this allows a nimble package
foo
to prefix all its defines byfoo.
, eg-d:foo.bar
implementation difficulty
easy, I can do it if this RFC is accepted
note
see also #269 for a proposal that enforces ODR (one definition rule), that is complimentary to this RFC.
The text was updated successfully, but these errors were encountered: