Skip to main content
Variables are the foundation of any program. In Standard, a variable name can be any alphanumeric value as long as it does not start with a number or a special character, and it may not contain a special character anywhere in the name. Variable names are case-sensitive, so myName and myname are treated as two distinct variables. To set a variable to a value, write the variable name followed by whitespace and the value you want to assign:

Types

Standard automatically infers and sets the type of a variable based on the assigned value. Once a type is established, the variable must maintain that type throughout its lifetime. The following built-in types are supported:

Null Types and Initialization

You can set a variable to null by following the variable name with null or nothing. The variable inherits a type the first time you assign it a non-null value:
In this example, username starts as null and receives its type when the user provides input.

Standards as Variables

Developers aren’t always working with native data types but with objects. Objects are Standards in the Standard System. To initialize a variable of a standard type, provide a variable name followed by the standard’s reference preceded by an @. You can then assign values to constraints by using the . accessor.
vehicle.stds
new_vehicle.std

Reserved Words

Variable names may not be a reserved word or built-in function name. They also may not share a name with any function you define in your own Standard code. The following words are reserved and unavailable for use as variable names:
Using a reserved word as a variable name will cause an error at runtime or unexpected behavior. Choose descriptive names that don’t conflict with Standard’s built-in vocabulary.