OpenModelica


Forgot password? | Forgot username? | Register

Management of public and protected variables

Management of public and protected variables

Hello,

I am currently trying to restrict access to some model variables by relying on public and protected keywords

I designed two models

class AccessRights
  Real publ;
protected
  Real protec;
end AccessRights;

class Glob
  AccessRights A;
equation
  A.publ = 10;
  A.protec = 1;
end Glob;

The Glob model is successfully compiled and a simulation is conducted (using OpenModelica v1.9.3). Only publ can be displayed in output (not A.protec). When I comment out the A.protec = 1 equation, I get an error (not enough equations).
The Modelica language specification (3.3, section 4.1) says that "Protected elements in classes cannot be accessed via dot notation. They may not be modified or redeclared in a class modification."

As a result, shouldn't the A.protec = 1 equation be deemed illegal ?

Thank you in advance

Edited by: FBeaude - Jan-06-16 11:51:56
Administrator has disabled public posting. Please login or register in order to proceed.

Re: Management of public and protected variables

I think you are right and it should trigger a warning or even an error message. Can you please open a ticket for this in the trac system?

Administrator has disabled public posting. Please login or register in order to proceed.
There are 0 guests and 0 other users also viewing this topic
You are here: