Outils pour utilisateurs

Outils du site


kmelia:types:start

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 here

Structured Types

Structured types are :

  • structures : struct
    • arrays : array[range]
    • range : min..max
    • enumerations : enum

    library contents here

Abstract Data Types

Only one default type here for the moment.

  • set : setOf

library contents 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

kmelia/types/start.txt · Dernière modification: 2018/04/03 16:59 (modification externe)