Include parent classes in process name/class reverse lookup #45
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.
A possible way to customize processes is to use class inheritance. However, a current limitation is that foreign variables hard-code external classes, making it difficult to customize a model by replacing a process class by one of its sub-classes.
This PR address this issue by also including parent classes in the process name/class reverse lookup that is used to link foreign variables to their corresponding process when building a new model. Using the example in the docs, it is now possible to do something like:
In the example above, the foreign variables declared in other processes of
alt_model
are now correctly linked to the'grid'
process even if they were declared likexs.foreign(UniformGrid1D, 'x')
, asAlternativeGrid1D
inherits fromUniformGrid1D
.One drawback (and possible breaking change) is that linking foreign variables is ambiguous when both conditions below are met:
object
)For example:
While the example above doesn't make any sense, I can't think about a real case where this should happen.
This feature is quite robust IMO, but it should be considered as experimental.