ModelicaSpecification
ModelicaSpecification copied to clipboard
Meaning of argument-less experiment annotation
Bringing up question as suggested in https://github.com/modelica/ModelicaSpecification/pull/2922#discussion_r639702197:
Quoting the grammar for the experiment
annotation:
"experiment"
[ "(" [ experimentOption { "," experimentOption } ] ")" ]
What is the purpose of allowing the annotation without argument list?
model M
annotation(experiment); /* Valid, but what is the purpose? */
end M;
Why don't we simply require the argument list?
Having an empty experiment would make sense if the experiment annotation was inherited, to mark the model as an experiment but the settings are elsewhere. (Or perhaps just stating it is an experiment; use default settings)
Having an empty experiment would make sense if the experiment annotation was inherited, to mark the model as an experiment but the settings are elsewhere. (Or perhaps just stating it is an experiment; use default settings)
To me, it would be more natural to express that with experiment()
instead, although I'm hesitant to consider anything without StopTime
a meaningful experiment.
Why is there even specific grammar for some of the annotations in the specification, while others are defined as records? The actual grammar of Modelica for annotations is annotation class-modification
, which is not consistent with the grammar given for experiment
.
OpenModelica ignores modifiers with neither submodifiers nor an expression (like Real x(start)
), so for what it's worth we currently ignore an experiment
annotation such as this. That might be wrong in this case since it means the model is not even marked as an experiment, but I guess that's what this issue is about.
See also #2852, #2314 and #2535.
Without reopening, let me just try to summarize how I interpret the resolution by #2999:
When an annotation is defined by a pseudo-record, the record constructor form must be used in order to express a valid annotation, so annotation(experiement)
is invalid (but unfortunately, invalid annotations like this are not errors), while annotation(experiemnt())
is valid:
model A
annotation(experiment(StartTime = -1.0));
end A;
model B
extends A;
/* This model has StartTime = -1.0, inherited from A. */
annotation(experiment); /* Not a valid experiment annotation; means nothing at all. */
end B;
model C
extends A;
/* This model has StartTime = 0.0, coming from the local annotation. */
annotation(experiment()); /* Valid annotation. */
end C;
Without reopening, let me just try to summarize how I interpret the resolution by #2999:
When an annotation is defined by a pseudo-record, the record constructor form must be used in order to express a valid annotation, so
annotation(experiement)
is invalid (but unfortunately, invalid annotations like this are not errors), whileannotation(experiemnt())
is valid:model A annotation(experiment(StartTime = -1.0)); end A; model B extends A; /* This model has StartTime = -1.0, inherited from A. */ annotation(experiment); /* Not a valid experiment annotation; means nothing at all. */ end B; model C extends A; /* This model has StartTime = 0.0, coming from the local annotation. */ annotation(experiment()); /* Valid annotation. */ end C;
experiment()
is not a record constructor in this context though, it's an empty class modifier. If the normal modifier semantics were to be used it wouldn't have any meaning either.
experiment()
is not a record constructor in this context though, it's an empty class modifier. If the normal modifier semantics were to be used it wouldn't have any meaning either.
This comment by @HansOlsson shows where the confusion comes from. I believe it is best we continue the discussion there.