'import'

import

Information

This information is part of the Modelica Standard Library maintained by the Modelica Association.

Import classes

Examples

class Lookup
  import SI = Modelica.Units.SI; // #1 (Try to avoid renaming imports!)
  import Modelica.Math.*; // #2 (Try to avoid wildcard imports!)
  import Modelica.Mechanics.Rotational; // #3
  import Modelica.Units.SI.{Molality, Molarity}; // #4

  SI.Torque torque; // due to #1 (Modelica.Units.SI.Torque)
  Rotational.Components.Inertia inertia; // due to #3 (Modelica.Mechanics.Rotational.Components.Inertia)
  Molarity c = 1; // due to #4 (Modelica.Units.SI.Molarity)
equation
  torque = sin(time); // due to #2 (Modelica.Math.sin)
  ...
end Lookup;

Syntax

See section on import_clause in the Modelica Grammar.

Description

Using import statements extends the static name lookup to additional import names. The generated import names are:

  • C for import A.B.C;
  • D for import D = A.B.C;
  • C and all other classes in B for import A.B.*;
Note

Especially the renaming and wildcard import statements should be avoided since they might lead to name-lookup conflicts.