====== Types and Fonctions in Kmelia ====== Kmelia types can be //predefined types// or //user-defined types//. Predefined types can be //primitive types// or //abstract data types//. * //primitive types// are defined directly in the grammar together with their usual operators. * //abstract data types// are specified in type libraries using function signatures and implementation. * //user-defined types// are defined in type libraries or in component types themselves. A (currently) restricted form of **Generic types**, **anchor type** and **subtyping** is allowed in Kmelia. * ''ANYTYPE'' which is the supertype common to all types except to Void. * ''LIKE'' is an anchor-type associated to the first value encountered in a function signature. In a Kmelia specification **Data Types** are used in the variable definition clauses (component, service...). name : String; tab: montablo; point_test : Point; swallowed_cards : setOf CashCard; other_cards : setOf CashCard; available_notes : Integer; intset:monset; intset2:setOf Integer ===== Primitive Types ===== //primitive types// are : * ''Integer'', ''Boolean'', ''String'', ''Char'', ''Void'' library contents [[kmelia:types:primitive|here]] ===== Structured Types ===== //Structured types// are : * structures : ''struct '' * arrays : ''array[range]'' * range : ''min..max'' * enumerations : ''enum '' library contents [[kmelia:types:structured|here]] ===== Abstract Data Types ===== Only one default type here for the moment. * set : ''setOf'' library contents [[kmelia:types:adt|here]] ===== User-defined Types ===== == In a Component definition == With the ''TYPE'' clause TYPES CashCard:: struct {code:Integer; ident:Integer; limit:Integer}; montablo:: array [1..10] of Integer; monset :: setOf Integer RVB :: enum {R,V,B}; == In libraries of types and functions == see [[libraries]]