Objects whose structure can be redefined

The problem with redefining structs is that all existing code using that struct would have to be recompiled, as the new number of fields necessarily means a different memory layout as well. Doing this on-the-fly would mean potentially having to recompile the very code you’re running right now while it’s running, and since that’s not allowed, struct redefinition at runtime isn’t either.

If you have the need to explore how your struct should look, try prototyping usind NamedTuples combined with Revise.jl, and only settling on a struct once you know how to best organize youre code.

If you could tell us more about what you’re trying to achieve, we may be able to suggest a more julian approach. Redefining existing structs feels very much like a workflow used in e.g. python (which is interpreted and not compiled, and thus doesn’t suffer from the above problem since everything is a dynamic lookup anyway).

3 Likes