Eliminate the need for @load_generated_functions.
#472
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR eliminates the need to call
@load_generated_functionsin order to make use of a generative function written in the static modeling language. Instead, new@generatedGFI methods (simulate,update, etc.) are defined for each static generative function. These GFI definitions are evaluated after theget_irandget_optionsdefinitions returned byGen.generate_generative_function, preventing world-age issues.Besides making the static modeling language easier to use, this change prevents incremental precompilation warnings and breakages which were occurring when multiple sub-packages called
@load_generated_functions, of the form:Minimal working example: TestPkg.zip
This warning occurs because
@generated function simulate(...)was being defined multiple times:TestSubPkgAthat calls@load_generated_functionsis precompiled.TestSubPkgBthat calls@load_generated_functionsis precompiled.The second definition overwrites the first definition for the exact same
@generatedmethod, leading to precompilation warnings. This PR addresses the issue by defining a different@generatedmethod for each new generative function.In addition to the main change:
load_generated_functionsor@load_generated_functions.@load_generated_functionsis no longer necessary.For documentation and docstrings, we may want to specify a version number, e.g. Gen v0.4.6, for when
load_generated_functionsis no longer necessary. But apart from that, I'm pretty sure this is safe for the rest of the Gen ecosystem!