Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
ldmud/doc/LPC/unions
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
30 lines (22 sloc)
1.11 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CONCEPT | |
unions | |
DESCRIPTION | |
Unions types are a declaration at compile time that a variable, | |
function parameter or function return value can be one of | |
several types. | |
Except for type checks using #pragma rtt_checks they have no | |
impact at runtime. There is no runtime union type, the concrete | |
value type is one of the possibilities of the union type. | |
Union types have no type names for themselves, they are declared | |
anonymously with the declaration of the variable, function | |
parameter or return type: | |
int|string var; | |
int|float fun(object|closure f); | |
When using union types as array member types they must be | |
enclosed with < >: | |
<int|string>* arr; /* An array of ints and strings. */ | |
int*|string* arr; /* Either an array of ints or | |
an array of strings. */ | |
/* There must be a whitespace between two consecutive < | |
to be not confused with the << operator: */ | |
< <int|string>*|object >* arr; | |