4.1. Binding types

Felix allows you to bind types like:
  type myint = "int";
When the target and source names are the same, the source string can be elided, and multiple type named at once:
  ctypes int, long, complex;
The type must be a first class type, that is, allocable, default initialisable, copy constructible, copy assignable, and destructible.

Non-first class type may also be introduced with the keyword incomplete:

  incomplete type myvoid = "void";
and may only be used as the argument of a pointer type constructor or argument to a binding construction for which the type makes sense in C/C++ context. For example:
  type pt[t]="?1*";
  typedef voidp = pt[void];
is acceptable usage because void* is a first class data type.

It is also possible to state that a type is a C++ POD, or Plain Old Data type:

  pod type int = "int";
In such a case, the garbage collector may elide applying a finalisation function to the type, improving performance.

The decoration:

  _gc_pointer type int = "X*";
tells the garbage collector the type is a pointer to Felix heap storage, and should be traced by the collector sweep when determining if storage is reachable. In this case, the pointer may be NULL, otherwise it must point to the client data part of a storage frame allocated by the collector. Such an type this denotes managed storage. This annotation is primarily provided so programmers developing Felix types in C++ can tell the Felix compiler the type is Felix compliant.

Type abstractions can be polymorphic. For example:

  type vector[t] = "vector<?1>";
Here the special encoding ?1 refers to the first type parameter.

Type bindings may also have a requirements clause:

  type vector[t] = "vector<?1>" requires vector_h;
See requirements for more details.