-
Notifications
You must be signed in to change notification settings - Fork 44
Description
This question concerns the following rule in https://specification.modelica.org/master/statements-and-algorithm-sections.html#while-statement:
Event-generating expressions are neither allowed in the expression nor in the loop body statements. A deprecated feature is that all expressions in a
while
-statement are implicitly insidenoEvent
.
Is the following deprecated according to the rule above?
model GenerateEventsTrueInWhile
function f "Function which does not generate any events, despite having GenerateEvents = true"
input Real u;
output Real y = cos(u)^2;
annotation(GenerateEvents = true, LateInline = true);
end f;
Real z;
Integer i;
Integer j = integer(time);
algorithm
z := 0;
i := 0;
while i < j loop
z := z + f(z); /* Has GenerateEvents = true, but will actually not generate events. */
i := i + 1;
end while;
end GenerateEventsTrueInWhile;
The use of LateInline = true
is not the main point of my question, but highlights the fact that the developer may propose that inlining of the function is performed late in the translation process.
I would prefer if it could be clarified that the above model goes under the deprecation rule, as this allows the rule to be checked early and without analyzing the body of the function.
A simple way to clarify the specification would be to add the following to the GenerateEvents
text:
A function with
GenerateEvents = true
should be considered event generating for purposes of determining where the function may be called, regardless of whether the function body contains any expressions which could actually generate events.