Konferensartikel

Operator Overloading in Modelica 3.1

Hans Olsson
Dassault Systèmes, Lund, Sweden

Martin Otter
German Aerospace Centre (DLR), Institute for Robotics and Mechatronics, Germany

Hilding Elmqvist
Dassault Systèmes, Lund, Sweden

Dag Brück
Dassault Systèmes, Lund, Sweden

Ladda ner artikelhttp://dx.doi.org/10.3384/ecp09430100

Ingår i: Proceedings of the 7th International Modelica Conference; Como; Italy; 20-22 September 2009

Linköping Electronic Conference Proceedings 43:23, s. 219-224

Visa mer +

Publicerad: 2009-12-29

ISBN: 978-91-7393-513-5

ISSN: 1650-3686 (tryckt), 1650-3740 (online)

Abstract

The constructor and operator overloading introduced in Modelica 3.1 is discussed. The goal is that elementary operators like “+” or “*” can be overloaded for records. This makes it possible to define and use; in a convenient way; complex numbers; polynomials; transfer functions; state space systems; etc. The chosen approach is different to other languages: (a) Only scalar operations need to be overloaded. Array operations are then automatically available; so the growth of the number of overloaded functions is avoided. (b) Automatic type casts between different data types is performed using overloaded constructor functions. Again this reduces the number of overloaded functions. (c) The approach is conservative and only allows overloading if no ambiguity is present; in order to not introduce pitfalls into the language. This is reached by basing the overloading on disjoint sets of matching functions and not on a priority match.

Nyckelord

Overloading; automatic overloading of arrays; overloading without ambiguities

Referenser

ANSI (1983): Ada Language Reference Manual. ANSI/MIL-STD 1815A.

Baur M.; Otter M.; and Thiele B. (2009): Modelica Libraries for Analysis and Design of Linear Control Systems. In F. Casella (editor): Proc. of the 7th Int. Modelica Conference; Como; Italy. www.modelica.org/events/modelica2009

Dymola (2009). Dymola Version 7.3. Dassault Systèmes; Lund; Sweden (Dynasim). Homepage: www.dymola.com.

ISO (1998): International Standard; Programming Languages – C++. ISO/IEC 14882:1998.

Modelica (2009). Modelica Language Specification 3.1. www.modelica.org/documents/ModelicaSpec31.pdf

Stroustrup B. (1994): The Design and Evolution of C++. Addison-Wesley.

Citeringar i Crossref