Opened 8 years ago

Last modified 8 years ago

#4317 new defect

Allow $ in component references and type names in mos scripts

Reported by: Adrian Pop Owned by: Martin Sjölund
Priority: high Milestone: Future
Component: Parser Version:
Keywords: Cc: Willi Braun

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 by Adrian Pop, 8 years ago

Summary: Allow $ component references and type names in mos scriptsAllow $ in component references and type names in mos scripts

comment:2 by Lennart Ochel, 8 years ago

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.

comment:3 by Adrian Pop, 8 years ago

I don't think is a problem to allow it in mos scripts only.

comment:4 by Adrian Pop, 8 years ago

Another way would be to use quoted identifiers, i.e. '$Sensitivities' is Modelica compliant.

in reply to:  4 comment:5 by Lennart Ochel, 8 years ago

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).

in reply to:  3 ; comment:6 by Lennart Ochel, 8 years ago

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.

in reply to:  6 comment:7 by Adrian Pop, 8 years ago

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.

Note: See TracTickets for help on using tickets.