Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't allow array subscripts in the argument to 'guess' #3533

Open
wants to merge 2 commits into
base: MCP/0031
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions RationaleMCP/0031/differences.md
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,9 @@ In more a complicated situation, this could be the length of a mechnical arm tha

Instead of controlling the guess values for the variable `x` via its `start` attribute as in full Modelica, Base Modelica makes use of an implicitly declared parameter `guess('x')`. This is called the _guess value parameter_ for `'x'`, and has the same type as `x`.

The syntax makes use of the new keyword `guess` which is not present in full Modelica. (Note that introducing a new keyword will not cause conflict with identifiers used in full Modelica code thanks to name mangling.)
The syntax makes use of the new keyword `guess` which is not present in full Modelica.
(Note that introducing a new keyword will not cause conflict with identifiers used in full Modelica code thanks to name mangling.)
The _component-reference_ argument to `guess` in the grammar is restricted to not contain any _array-subscripts_.

Since the declaration of `guess('x')` is implicit, a declaration equation cannot be provided in the same was as for a declared parameter. Instead, a special form of _parameter equation_ is used, where the parameter being solved must appear on the left hand side, and the equation shall be solved with causality so that the right hand side can be overridden during initialization (that is, after translation). In the grammar, it is an new alternative in _generic-element_:

Expand Down Expand Up @@ -1207,7 +1209,9 @@ initial equation
prioritize('x', 2); /* The guess value priority of 'x' is 2. */
```

The second argument of `prioritize` – denoted _priority_ in the grammar – shall be an `Integer` constant. Lower value means higher priority; that is, when making a choice based on priority, the variable with lower _priority_ value should be given precedence.
The _component-reference_ argument to `prioritize` in the grammar is restricted to not contain any _array-subscripts_.
The second argument of `prioritize` – denoted _priority_ in the grammar – shall be an `Integer` constant.
Lower value means higher priority; that is, when making a choice based on priority, the variable with lower _priority_ value should be given precedence.

Specification of priority is only allowed for components whose guess value parameter is explicitly present in the model. Example:
```
Expand Down Expand Up @@ -1259,7 +1263,9 @@ This is defined to mean the same as:
initial equation
prioritize('x', 2)
```
That is, in the syntactic sugar form, `prioritize` is used with different arguments compared to its basic form in an initial equation. In the syntactic sugar form, `prioritize` is wrapped around the right hand side of the parameter equation, and the variable to which the priority belongs is given by the left hand side, extracted from the `guess` wrapper.
That is, in the syntactic sugar form, `prioritize` is used with different arguments compared to its basic form in an initial equation.
In the syntactic sugar form, `prioritize` is wrapped around the right hand side of the parameter equation, and the variable to which the priority belongs is given by the left hand side, extracted from the `guess` wrapper.
Note that the _component-reference_ restriction for the first argument of `prioritize` is only applicable within _prioritize-equation_, not within the syntactic sugar form _prioritize-expression_.

### The `nominal` attribute

Expand Down