Problem of world age in application

in graphic application that use Gtk4 and Gadfly I have a function that create functions by Meta parsing and evaluating the text of GtkEntry widget.
these functions are well accepted in plot function and from the REPL but when I invoke them from signal handlers like those of buttons i get an error saying that the function is too new in the world age to be applicable.
I don’t undersand this message and don’t know how to solve the problem.
thanks for any contribution

The basic problem is that you have a long running function and new functions are created while it runs. Due to performance reasons a function can only call older functions essentially. To work around this you need to use Base.invokelatest. see e.g. this SO thread for more details

2 Likes

thank you abraemer I’ll get more information and then test and reply.

I tested the Base.invokelatest method as suggested by abraemer but it only wok for one call, in my application I have an array to fill with float values and I receive the same error message about world age when doing so. I tested the Base.invoke_in_world with different word counters but the error persist
it is true that I don’t understand the subject.
thanks for any suggestions

For every call where you get this world age problem you’ll have to use Base.invokelatest. Ideally you’d structure the code such that is only in one place.
Without you providing some code, there is not much else we can do for you.

I am not sure whether RuntimeGeneratedFunctions.jl can help here. But you can try it.