13: Aliases [✓] - royal-lang/rl GitHub Wiki

Aliases are similar to C/C++'s #define except for that they don't allow for any arbitrary piece of code.

Aliases only allows for syntactically valid Royal expressions and types. This ensures safety when using aliases.

alias NAME = EXPRESSION_OR_TYPE;
alias NAME(PARAMS) = EXPRESSION; // The params only include names (not types etc.) - The expression can use the params.

Example:

alias shortName = thisIsAVeryLongTypeNameThatNobodyWantsToType;
alias shortGenericType(T) = thisisAVeryLongGenericTypeNameThatNobodyWantsToType(T);

var shortName a;
var shortGenericType(int) b;

...

alias sq(x,y) = x * y;

var int x = 10;
var int y = 10;

var int z = sq(x, y); // Translates to: var int z = x * y;