Dodo doc > Types > Use of Variables as Type


Use of Variables as Type

A variable name can be used instead of a type name in declarations. In that case, the type is the same as the variable type except that the default value is the specified variable.

Examples:

address address_line1
double speed(double distance, time) = distance / time
drawing draw()

Note: If the variable is the default value of a type, writing the variable name is effectively the same as writing the type name. For example, writing "class" is the same as writing "Object", or writing "int" is the same as writing "Integer".

Rationale: this rule frees the programmer from having to define a new type every time the default value of a variable differs from the type default. It allows more friendly names to be used as types, notably extended variable names and names inspired from C types.

^ 4.3. Use as Prototype

v 4.5. Type Members