.ModelicaReference.'import'

Information

Import classes

Examples

class Lookup
  import SI = Modelica.SIunits; // #1
  import Modelica.Math.*; // #2 (Try to avoid wildcard imports,
                          //     consider using #1 or #3  instead!)
  import Modelica.Mechanics.Rotational; // #3

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

Syntax

class_definition :
   [ encapsulated ]
   [ partial ]
   ( class | model | record | block | connector | type |
     package | function )
   IDENT class_specifier

class_specifier :
   string_comment composition end IDENT
   | "=" base_prefix name [ array_subscripts ] [ class_modification ] comment
   | "=" enumeration "(" ( [enum_list] | ":" ) ")" comment

composition  :
   element_list
   { public element_list |
     protected element_list |
     equation_clause |
     algorithm_clause
   }
   [ external [ language_specification ]
              [ external_function_call ] [ annotation ";" ]
              [ annotation  ";" ] ]

element_list :
   { element ";" | annotation  ";" }

element :
   import_clause |
   extends_clause |
   [ final ]
   [ inner | outer ]
   ( ( class_definition | component_clause) |
     replaceable ( class_definition | component_clause)
        [constraining_clause comment])

import_clause :
   import ( IDENT "=" name | name ["." "*"] ) comment

Description

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

Note

Especially the last wildcard import statement should be avoided since it might lead to name-lookup conflicts.


Generated at 2020-06-05T07:38:22Z by OpenModelica 1.16.0~dev-420-gc007a39