The Freya Programming Language

Data types

See also

Freya fully supports .NET's Common Type System. Freya allows you to access any public type published by any .NET assembly, and you can write with Freya any kind of type declaration supported by the .NET Framework.

In this section

Predefined data types

Though you can access any data type from the CLR using a simple and uniform notation, Freya predefines some identifier at the global level for the most frequently used data types.

All Freya compilable projects are made of type declarations. So, your task as Freya developer is writing the type declarations your project requires. These are the type declarations allowed in Freya:

Classes

Classes are reference types that encapsulate both data and code. All other Freya types are based, in one way or another, in classes, and they are the most frequently used type kind in the .NET Framework.

Records

Records are very similar to classes, but they are value types, instead of reference types. Though they have some important limitations compared to classes, they still are very useful, since their instances don't require memory allocation from the dynamic memory pool available to the process or library.

Interfaces

Interfaces are abstract reference types that only encapsulates code, instead of code and data as most other types. Their primary use is as contract definitions. You cannot create objects directly from an interface type. Instead, interfaces must be implemented by classes or records.

Delegates

Delegates are special class declarations that encapsulates pointers or references to methods defined inside other types.

Enumerations

Enumerations are value types that are declared by defining a set of named constants.

All of the above declaration types, excluding enumerations, support genericity: they can specify type parameters, which act as placeholders for specific data types. The programmer must supply concrete data types for these parameters before using a generic data type.

You can also use constructed data types, created from the above mentioned basic data types:

Array types

Array types allow representing and managing simple series of items sharing the same type. They enjoy a special and very efficient implementation by the Common Language Runtime. Freya supports both one-dimensional arrays, including jagged arrays, and multidimensional arrays.

Closed generic types

Generic types defer their full definition by introducing type arguments. Before you can use a generic type definition, you must supply concrete types for each of these type parameters. Types constructed this way are called closed generic types.

Nullable types

Nullable types are special value types, created from the predefined System.Nullable[T] generic type. Freya provides special syntactic support for nullable types.

See also

The Freya Programming Language
Program and file structure
Inheritance
Generics
Type members
Statements
Expressions