-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
mapexpr argument for include: transform each parsed expression #34595
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
Conversation
|
@JeffBezanson, where is a module's |
|
I like the mapping function as the first argument. What else would one pass there, after all? |
|
If I do julia> module Foo; end; methods(Foo.include)
# 1 method for generic function "include":
[1] include(x) in Main.Foo at REPL[1]:1where is Update: I found it — it's in |
97fe1e7 to
3a0f5ff
Compare
|
Rebased. Is there anything else that is needed here? |
|
I think only for @JeffBezanson to have a look. He was traveling last week so a bit occupied. He'll probably be able to take a look and merge if he approves this week. |
This PR adds an optional
mapexprkeywordfirst argument toincludeandinclude_string, allowing you to specify a function that rewrites each expression after it is parsed. I've needed this functionality several times, e.g. in SoftScope.jl and ChangePrecision.jl, and it is tricky implement manually in a way that preserves line-number information and other semantics ofinclude.Moreover, now that #33864 has merged, I would like to use the "official"
REPL.softscope!function in IJulia instead of SoftScope.jl, or equivalently changeSoftScope.jlto use this function on newer Julia releases. With this PR, one can just passREPL.softscope!toinclude_string.To do:
x->xadds a 2–3% overhead toinclude_stringmeasured for"nothing\n"^10000, but I eliminated this by optimizing the default case ofmapexpr === identity.