-
-
Notifications
You must be signed in to change notification settings - Fork 5.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 "#pragma compile [true]" for opt-in to automatic compilation #12475
Conversation
7692b69
to
de4605c
Compare
I think that having a general |
Specifically, I dislike the |
I'm fine with removing the All of the alternatives for this seem worse (tie compilation to Pkg, require double parsing or (worse) double eval, have per-module rather than the actual per-file semantics of our compiler, etcetera). And without automated opt-in, |
Sounds good to me. Overall, I think we've gotten around #7449 quite well with Compat, but this seems like a compelling-enough case where we need some kind of pragma. Perhaps that's a good compat rule of thumb; use it anywhere we can, with the |
My biggest dislike of this is that it's in a comment. We're now making the content of comments semantically meaningful for the first time, because we couldn't agree on the need far enough in advance to give pragmas a recognized dedicated syntax for compatibility. This can't be the permanent way we do pragmas - code generated programmatically won't have any way of representing them. Is it really so intractable as
? |
Updated to |
Please see my comment #12462 (comment) about adding a macro with no arguments |
@tkelman, your solution requires the file to be |
ismatch(r_compilable, s) && return true | ||
ismatch(r_ncompilable, s) && return false | ||
else | ||
return default |
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 think this does the wrong thing for lines inside a block comment. Or #pragma compilable
would also have to be documented as needing to come before any multi-line block comments.
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.
Oh multiline comments, whoever implemented such an annoying feature?
Initially, we could just tend to document it as coming before #= ... =#
block comments (in practice I don't think this would affect people much), but I agree that you'd probably want to relax that eventually. Fortunately, parsing comments (even with nesting) is easy, and this could be added incrementally.
@stevengj I don't think that's correct, same as with what I was proposing, because the parsing code can short-circuit out of parsing/evaluating the rest of the file if it wants. (I tested that in a dumb way by causing a syntax error in an included file, and I saw that the rest of the file was not parsed or evaluated.) |
… a module is required (closes JuliaLang#12462)
Closing in favor of #12491 |
This PR implements automatic opt-in to compilation for modules, as discussed in #12462. In particular:
Foo
's fileFoo.jl
starts with#pragma compile [ true]
(before any non-comment code), thenrequire(:Foo)
(henceimport
orusing
) will automatically invokeBase.compile(:Foo)
.Base.compile
, however.)#pragma compile false
at the top of the module, thenBase.compile
will throw an error for that module. (SinceBase.compile
is recursive, this will also throw an error if you attempt to compile a module that requires a non-compilable module.)(In the future, it might be nice to implement compilation of modules that depend on non-compilable modules, but this is new functionality and should be a separate PR.)
Probably better to merge this after #12448 (
.ji
magic header) and #12458 (automated recompilation).