ModelingToolkit.jl icon indicating copy to clipboard operation
ModelingToolkit.jl copied to clipboard

Cannot add both default value and description to variables created in multiline statements (but parameters work).

Open TorkelE opened this issue 10 months ago • 2 comments

Simple MWE:

using ModelingToolkit

@parameters begin
    p = 1.0, [description="A parameter."]
end # Works
@variables t X(t) = 1.0 [description="A variable."] # Works
@variables begin
    t
    X(t) = 1.0, [description="A variable."]
end # ERROR: syntax: misplaced assignment statement in "[description = "A variable."]" around

TorkelE avatar Apr 15 '24 16:04 TorkelE

Vanilla @variables doesn't support that; I'll see how that can be added. But note that inside the @mtkmodel, such a thing just works.

ven-k avatar Apr 16 '24 08:04 ven-k

Sounds good. There are quite a few situations where one uses this outside of @mtkmodel. Especially if you have a lot statements like this, things become unreadable without begin ... end blocks. This is not very urgent, but definitely something it would be good to fix sooner rather than later.

TorkelE avatar Apr 16 '24 13:04 TorkelE