-
-
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
Implement RFC 416: lazy symbol semantic checking: enable cyclic deps, remove need for fwd decls, etc #18818
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Araq
reviewed
Sep 7, 2021
timotheecour
force-pushed
the
pr_lazysemcheck
branch
from
September 7, 2021 19:07
bc553cc
to
968bac8
Compare
Varriount
changed the title
fix RFC 416: lazy symbol semantic checking: enable cyclic deps, remove need for fwd decls, etc
Implement RFC 416: lazy symbol semantic checking: enable cyclic deps, remove need for fwd decls, etc
Sep 7, 2021
What are the semantic differences when the flag is enabled (aside from the general lazyness)? I assume that the intention here is to eventually make this mode the default. |
timotheecour
force-pushed
the
pr_lazysemcheck
branch
3 times, most recently
from
September 9, 2021 16:49
2ab123e
to
d34ed3d
Compare
timotheecour
force-pushed
the
pr_lazysemcheck
branch
from
September 9, 2021 23:35
6ea6dd5
to
15a308a
Compare
timotheecour
added a commit
to timotheecour/balls
that referenced
this pull request
Sep 10, 2021
This was referenced Sep 10, 2021
This reverts commit 15a308a.
timotheecour
force-pushed
the
pr_lazysemcheck
branch
from
October 10, 2021 00:50
db18966
to
764fe81
Compare
33 tasks
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. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
IMO this is the most important feature that was missing in nim, lack of cyclic imports was causing headaches for project organization with long ranging effects. This PR fixes this.
semantic notes
epilogue: semchecking of unused symbols
local epilogue is triggered by
compiles
and macro typed paramscompiles
is also lazy, but it triggers a local epilogue for the symbols in the generated code:likewise for typed macro params; note that the epilogue only concerns symbols in the generated code, it won't trigger exhaustive semchecking for unrelated code, eg:
implementation notes
seq[TOptionEntry]
is replaced by a heap allocated POptionEntry which contains parent references; this allows retrieving efficiently the correct context at declaration timeXDeclaredButNotUsed
,UnusedImport
are processed after epilogue and work as you'd expect them to; they also work with nested symbols, unlike before PR2-pass vs 3-pass rountine semchecking
in this PR, each symbol from a routine declaration is semchecked at most twice:
this works but has downside of causing all overloads to be fully semchecked when the name is used:
in future work, this can be refined by using 3-pass semchecking, which splits the 2nd pass into a pass that only semchecks declaration, and if the symbol is accepted for sigmatch, then the routine body is semchecked only when needed, which enables more laziness and further reduces limitations on cycles
limitations to what declarations can be lazy semchecked
symbols that have an implicit behavior cannot be semchecked lazily (at least their declaration) because we'd have no way to guess whether an implicit rewrite can use those; this doesn't cover many symbols though; only the following are semchecked in a non-lazy way:
macro optOps{ (
+|
-|
*) ** a }(a: TMat): untyped
, see trmacros_various.nim)=destroy
and=copy
as they affect semantics implicitly{.gensym.}
defined inside macrosfuture work can lift some of those restrictions
backward compatibility
this PR (after i remove temporary debugging/testing) should have no semantic differences by default; the lazy semchecking should only be enabled by a opt-in flag
TODO
isCompilerProc
--experimental:lazy
(simple), or--lazy:on|off|aggressive
where on would mean semcheck in epilogue, aggressive would mean skip smechecking of unused symbols in epiloguetype _ = typeof(foo)
)status
lazy:on
inconfig/config.nims
:./koch --localdocs:/tmp/htmldocs docs
works (including all the runnableExamples)./koch docs
works (ditto)links