- Index
- » Programming
- » Modelica Language
- » parameter values with equations?
parameter values with equations?
parameter values with equations?
In Modelica modifications are made by means of equations (for instance in the following examples taken from sect. 7.2 of ModelicaSpec32):
Real altitude (start=59404)
parameter Real x=2;
To my understanding these should be assignments instead:
Real altitude (start:=59404)
parameter Real x:=2;
I say this because these modification copy the value at the right of sign "=" or ":=" into the variable at its left.
Indeed the Modelica grammar allows for these cases both "=" and ":=", but in the examples typically "=" is used and common tools' GUIs (such as OMEdit) use "=" when the user chooses parameter values.
I'm pretty sure that this has been chosen on purpose by Modelica designers and tool programmers.
But I cannot envisage the reasoning. They wanted there to be equations (at least either equations or assignments). To me they are definitely assignments, not equations.
Any opinions or comments about this?
- ceraolo
- 147 Posts
Re: parameter values with equations?
You are only supposed to be able to use ":=" for bindings in functions (and then only use ":="). In all other cases "=". In the OpenModelica, we cannot distinguish between the two so both are accepted. Try for example:
Code:
loadString("model M
Real r := time;
end M;");
list();
- sjoelund.se
- 1700 Posts
Re: parameter values with equations?
I see.
But what seems strange to me is that Modelica, that is so carefully designed in its syntax, and that is built from the ground up in the distinction between assignments (n algorithms, implementing imperative programming) and equations (in equation sections, implementing the declarative programming paradigm) is so vague about bindings.
I really don't understand why they allow bindings written in equation form.
It seems to me that they really indicate assignments. But maybe I'm missing something.
- ceraolo
- 147 Posts
- Index
- » Programming
- » Modelica Language
- » parameter values with equations?