-
-
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
RFC: during using
, define module before include, to solve a minor data-race on UUID
#43257
base: master
Are you sure you want to change the base?
Conversation
Passing the UUID via global state can be a data-race, and passing it via TLS seems more awkward than necessary. Instead, we define that `require` implicitly makes the module it expects. We make the module a baremodule initially, until the user calls `module Name` (or `using Base` and defines `include` and `eval`). The module call also (re)sets the scope of the `__init__` call, to preserve the prior behavior and order of it.
|
||
is_root_module(m::Module) = @lock require_lock haskey(module_keys, m) | ||
root_module_key(m::Module) = @lock require_lock module_keys[m] | ||
function PkgId(m::Module) |
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.
Seems like this can stay in pkgid.jl?
} | ||
if (jl_generating_output()) | ||
jl_errorf("cannot replace module %s during compilation", jl_symbol_name(name)); | ||
jl_printf(JL_STDERR, "WARNING: replacing module %s.\n", jl_symbol_name(name)); |
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.
This will break some workflows.
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.
workflows that print WARNINGs are not stable
try | ||
Base.include(Base.__toplevel__, input) | ||
eval(newm, :(baremodule $(nameof(newm)); $include($newm, $input); end)) |
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.
Is the extra baremodule
layer doing anything here? It seems to me evaluating inside newm
is already enough?
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.
Running __init__
functions is tied to syntactic module definitions
Passing the UUID via global state can be a data-race, and passing it via
TLS seems more awkward than necessary. Instead, we define that
require
implicitly makes the module it expects. We make the module a baremodule
initially, until the user calls
module Name
(orusing Base
anddefines
include
andeval
). The module call also (re)sets the scopeof the
__init__
call, to preserve the prior behavior and order of it.