Recommended ways to work around world age issues in v0.6?


#1

I ran into a problem yesterday with https://github.com/JuliaIO/Formatting.jl not working on v0.6 (I posted the following issue: https://github.com/JuliaIO/Formatting.jl/issues/27, as I don’t know how to work around this issue yet - once I do, I can submit a PR to fix the problem).

Basically, the code is using quote and eval to generate a function that wrap a call to the @sprintf macro with specific arguments, and then store those functions for reuse in a Dict, the first time that format has been seen, and then immediately calling that function.
That seems to be pretty useful functionality, however it doesn’t work anymore due to (AFAICT) https://github.com/JuliaLang/julia/pull/17057.

What would be the most performant way of doing this in v0.6?


#2

I don’t know if it is the most performant way of handling this, but I’ve found at least one workaround finally:

if VERSION >= v"0.5.0"
    cfmt( fmt::ASCIIStr, x ) = eval(Expr(:call, generate_formatter( fmt ), x))
else
    cfmt( fmt::ASCIIStr, x ) = (generate_formatter( fmt ))(x)
end

I’m concerned, because normally you don’t want to call eval, I’m hoping somebody can clarify this issue, as to how this will affect performance.


#3

That’s precisely what the documentation suggests: http://docs.julialang.org/en/latest/manual/methods.html#Redefining-Methods-1


#4

Ah, good! I’d been looking in the discussion about the change in the GitHub PR comments, and hadn’t seen a recommended workaround there, and had heard about an invokelatest function, but I wasn’t able to find that in master.