Opened 8 years ago
Last modified 8 years ago
#4317 new defect
Allow $ in component references and type names in mos scripts
Reported by: | adrpo | Owned by: | sjoelund.se |
---|---|---|---|
Priority: | high | Milestone: | Future |
Component: | Parser | Version: | |
Keywords: | Cc: | wbraun |
Description
Currently we don't allow the $ char in mos scripts but some of the code we generate for example for parameter sensitivity use the $ sign:
https://openmodelica.org/doc/OpenModelicaUsersGuide/latest/parametersensitivity.html
The problem is that one cannot use val($x, 0) and any other functions that have a variable name containing $ as input.
Change History (7)
comment:1 Changed 8 years ago by adrpo
- Summary changed from Allow $ component references and type names in mos scripts to Allow $ in component references and type names in mos scripts
comment:2 Changed 8 years ago by lochel
comment:3 follow-up: ↓ 6 Changed 8 years ago by adrpo
I don't think is a problem to allow it in mos scripts only.
comment:4 follow-up: ↓ 5 Changed 8 years ago by adrpo
Another way would be to use quoted identifiers, i.e. '$Sensitivities' is Modelica compliant.
comment:5 in reply to: ↑ 4 Changed 8 years ago by lochel
Replying to adrpo:
Another way would be to use quoted identifiers, i.e. '$Sensitivities' is Modelica compliant.
That would be Modelica-compliant but maybe not unique.
I propose to use something like --sensitivitiesPrefix="whatever" to change the prefix for the sensitivities analysis and to use something Modelica compliant as default value (e.g. Sensitivities).
comment:6 in reply to: ↑ 3 ; follow-up: ↓ 7 Changed 8 years ago by lochel
Replying to adrpo:
I don't think is a problem to allow it in mos scripts only.
I don't like to have the $ in order to make it easier (or even possible) to exchange models and results between Modelica tools.
comment:7 in reply to: ↑ 6 Changed 8 years ago by adrpo
Replying to lochel:
Replying to adrpo:
I don't think is a problem to allow it in mos scripts only.
I don't like to have the $ in order to make it easier (or even possible) to exchange models and results between Modelica tools.
True, but on another note we are quite consistent with the use of $ in generated names.
However, in this case, I guess we should not do that so the variables can be used easily, so I support your proposal with --sensitivitiesPrefix="whatever". The default could be _omcSensitivities.
I am not sure if we should allow $ in component references. Is there really no better way to generate unique names for those generated variables? One option would be to use a user-definable prefix.