In Scrall there are three kinds of variables: scalar variable, table variable, and instance set variable. Before diving into the details of each variable type, there are some general principles.
A variable is always local to the activity in which it is defined. There is no such thing as a global variable in xUML. To persist a value outside the scope of an activity, it must either be stored as part of a class model’s population as a value of an attribute of some instance or sent as an output parameter value in a signal or domain interaction.
Variables are usually defined implicitly through assignment. In other words, the assignment operator establishes the type of the LHS where the variable sits.
There are some cases where it is preferable to explicitly define a variable type prior to assignment. Once a variable is defined it may not be later re-defined either implicitly or explicitly.
Local context is implied
A variable name may not conflict with any local class or attribute name. This eliminates the need for a
self keyword to resolve duplicate names. In fact, Scrall has no such
self (or similarly purposed but otherwise named) keyword. In other words, if a local class or attribute name is used in an activity, the local context is presumed.
So if you are defining an activity on the Aircraft class, you cannot define an
aircraft variable. But you might use the name
my aircraft, or even
the aircraft. If there is an Aircraft.Altitude attribute, you cannot define an
altitude variable, but you might try
current altitude. This means, of course, that if the class model is edited, say to add a
Current altitude attribute, it could cause a naming collision in your action language.
Every variable holds a value at all times
There is no concept, in Scrall, of an uninitialized variable.