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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is prepending
$MTK.
to everything really the solution? What if we did this instead:Also wouldn't this need to be done in more places? e.g. where
@variables
is called.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the discussion around https://discourse.julialang.org/t/adding-method-to-function-in-macro/128613/6 . If you're going to
esc
the expression, then you need either$MTK.AbstractSystem
or$AbstractSystem
, but there are places where the latter will fail. In particular, you can't$@some_macro
obviously. I always use the former style for that reason, but I don't mind changing this PR to$AbstractSystem
if that's your preference.Yes, absolutely. I didn't want to venture outside of my MTK comfort zone.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, thanks for clarifying.
$MTK
is fine, then.While parsing
@variables
inside@mtkmodel
, we generate code that callsSymbolics.@variables
andMTK.@parameters
. I assume those need to be qualified as well?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I always prefix functions, types and macros with
$MyModule.
when usingesc
. It's the flip side of skipping macro hygiene. It can also prevent unnecessary conflicts if ModelingToolkit and SomeOtherLibrary export the same symbol.In this particular case it doesn't matter because the user will feel compelled to
import ModelingToolkit: @variables
anyway, but that's not reliable in general.