You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In 12.3 Pure Modelica Functions there is a list of situations where it's allowed to call an impure function, it doesn't mention clocked equations/statements. Shouldn't it be allowed there as well?
model M
Clock c = Clock(1);
Real x;
Real y;
equation
x = sample(time, c);
y = impureFunction(x);
end M;
Feels a bit unnecessary to require the y = ... to be wrapped with when Clock() then.
The text was updated successfully, but these errors were encountered:
HansOlsson
added
the
discussion
Indicates that there's a discussion; not clear if bug, enhancement, or working as intended
label
Nov 22, 2024
On one hand I see that point, but on the other hand I see a problem with usability and diagnostics.
Consider:
model MinputReal x;
outputReal y;
equation
y = impureFunction(x);
end M;
model A
M m(x=sample(time, Clock(1));
end A;
Here the call is ok in A - but in M it would not be legal as it is not clocked. Assuming we want to allow the first model, the question is what to do with M:
Say that it is illegal and have some weird rule that it must be clocked in the same model. (Not clear how.)
Say that it is legal in A and give diagnostics for M ignoring that possibility. (Users of the feature will complain.)
Say that it is legal in A and give diagnostics for M including that possibility, which will mean that every use of impure functions we have to include it.
Based on that I find the idea of explicitly making it clocked
model MinputReal x;
outputReal y;
equationwhen Clock() then
y = impureFunction(x);
end when;
end M;
an acceptable way of writing to avoid all of that.
As follow-up, having some other way of making models/blocks clocked is also something we could consider, but we would then need to differentiate between a model being clocked, vs. clocked with one clock.
I your example I would say M is illegal therefore A is also illegal.
But if they are illegal, I find it difficult to say that the equations are legal "just" because it is part of the same model (I realize that the discussion would benefit from having different names for the different models :-)
In 12.3 Pure Modelica Functions there is a list of situations where it's allowed to call an impure function, it doesn't mention clocked equations/statements. Shouldn't it be allowed there as well?
Feels a bit unnecessary to require the
y = ...
to be wrapped withwhen Clock() then
.The text was updated successfully, but these errors were encountered: