Import classes
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;
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
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.*;
Especially the last wildcard import statement should be avoided since it might lead to name-lookup conflicts.