|The Hyper Programming Language|
|home||language reference||compiler||hyper on launchpad|
Literal expressions are the simplest of all expressions. All other types of expressions are composed of other expressions but literal expressions are not. Literal expressions are also called just literals. Every literal has a type that is a built-in type. Some literals are just a reserved keyword.
Hyper has the following types of literals:
These are the keywords true and false. Their type is bool.
This is represented by the keyword null. It is a universal pointer constant that can be used for any pointer type. It doesn't really have a type of its own, and it is used to indicate that a pointer doesn't point to anything.
This is represented by the keyword system and refers to the main namespace of the standard library.
The keyword this refers to the current class instance. Of course, it can be only used in a context where there actually is such an instance. So it cannot be used, for example, in a static procedure.
A string constant is represented by some text enclosed by double quotes. Its type is of course string. There are currently no escape sequences supported. A double quote can be embedded in a string literal by doubling it.
A char constant is for now just represented as a Unicode character enclosed by single quotes. Its type is char.
An identifier is used to refer to anything with a name. An identifier starts with a letter and can contain letters, digits and underscores. It cannot contain whitespace. I am still thinking about reserving some identifiers for special purposes (like the ones ending in 2 underscores etc.). Its type is the type of the thing it refers to.
If the identifier refers to a procedure and no procedure call expression is present, then an implicit procedure call is applied.
These are divided in 2 groups: the floating-point numbers and the integral numbers. Numbers with a decimal dot are floating-point numbers.
An integral number literal is by default of an unsigned type (one of the natXX types). Only if it is a negative number it will have a signed type (one of the intXX types). The type it has will have a fixed size (byte, nat16, int32 etc.) and the smallest possible type will be used. Hyper does not have suffixes for integral numbers to indicate their type.
A floating-point literal is by default of type real. You will have to use a suffix to give the literal another type. For single this is a lowercase 's', and for double this is a lowercase 'd'. (The current compiler does not yet support these suffixes)