-
-
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
[WIP] exportable pragmas #13016
[WIP] exportable pragmas #13016
Conversation
4a6ea3d
to
428df67
Compare
For some reason I missed this PR, I like it much better than #13030. Definitely how we should do things IMO, the pragma pragma always was weird. |
The root cause of all this is we're binding identifiers, not symbols; if you can think of a way to bind symbols, that would improve things. |
341a67e
to
a01e530
Compare
PTAL, I've resolved the main issues:
|
1acdb47
to
8f7539e
Compare
noteone question is how to handle this:
|
I doubt this answers your question directly but effectively builtin pragmas are in their own namespace and only unknown pragmas are mapped to templates or pragma pragmas. I doubt too much can be done about this design without breaking too much code out there. This implies that bulitin pragmas inside templates should get the same special handing as e.g. the |
I believe this PR, once finished, will allow template lenTuple*(t: tuple): int {.since: (1, 1).} =
## Return number of elements of `t`
lenTuple(type(t)) because it gives: but once pragma's use PSym that bind locally, this should work |
The CIs are all red but the feature is decent, please continue to work on it. |
This pull request has been automatically marked as stale because it has not had recent activity. If you think it is still a valid PR, please rebase it on the latest devel; otherwise it will be closed. Thank you for your contributions. |
This pull request has been automatically marked as stale because it has not had recent activity. If you think it is still a valid PR, please rebase it on the latest devel; otherwise it will be closed. Thank you for your contributions. |
see tests
small example:
caveats (help welcome)
right now this has some limitations:can't use a classical user defined pragma pragma inside a template pragmaEDIT: actually it's possible for local pragma pragma, see tests; for non-loacl pragma pragmas, would require also exportable pragmas (v2) #13030can't use non exported template pragma inside exported template pragmaEDIT: works, see tests[EDIT] ideally the pragmas would be evaluated at definition time and bind to symbols, not identifiers; see examplemyfooHijacked
illustrating how a locally defined template pragma affects an imported pragma because it hijacks the identifierEDIT: this now works, no hijacking happens, see tests
note
see also #13030 for an alternative implementation