Is there a way to manually trigger a world_age update?

I’m confused about what you are trying to do.

invokelatest is needed when you are in a function f trying to call a function g, but you want to invoke a version of g that is newer that the version of f that is currently running. The “current world” is the age of the code that is currently running.

You obviously cannot recompile f while you are running it. But this means that you can’t invoke g in the “normal” way — for a normal function call, g might have been inlined (which will obviously not call the latest version). Also, when f was compiled, type inference (hopefully) determined the return type of g and specialized f’s code for that result … the latest g may have changed its return type.

So, invokelatest(g, ...) calls g in a way that always chases the Function pointer, and the compilation of f assumes that the return type is Any (i.e. the result is type unstable, because the return type of g may change). This obviously hurts performance, which is why you only use invokelatest in specialized circumstances.

5 Likes