identifiers - Manhunter07/MFL GitHub Wiki
Identifiers in the sense of programming are names that declared entities from within the current scope can be reached by. The represent the declared names of objects such as packages, constants, variables, functions or similar entities.
When declaring an object, its identifier(s) must follow the restrictions put uppon them by the architecture of the programming language. MFL follows the same naming restrictions as most other object-oriented or imperative programming languages. They are identical to those of Pascal, with the slight difference that keywords cannot be escaped using &
.
Identifiers may start with an uppercase or lowercase letter from A
to Z
(a
to z
respectively) or an underline, and may contain the same set of characters plus the addition of digits from 0
to 9
.
Spaces, operators, comments or any other special characters, including language-specific letters like the German umlauts (Ä
, Ö
, Ü
) or eszett (ß
) are not possible. They are, however, possible inside Strings literals which pose no restrictions on characters whatsoever.
Some valid identifiers in MFL could be: sample
, SamPle
, SAMPLE
, Sample_0
, _sam_ple
or _0_Sample
.
Invalid identifiers are for example: 0_Sample
, Sam ple
, Sam-ple
*, Sämple
, ?(Sample)
* or Sam|ple
.
*) Although these would be valid expressions and could be evaluated, they are not a possible identifiers for themselves.
Qualified identifiers are identifiers that include the whole scope path they are declared in. This usually includes the package name and the object name for global identifiers. Function parameters and function-local pseudo objects do not have a qualified identifier and can therefore not be explicitely addressed if re-declared.
Qualified identifiers including the package and object name contain both, separated by a single dot (.
). Examples for qualified identifiers are: System.Sin
, System.Info.Get
, System.Thread.ID
or MyPackage.MyObject
. For most packages, a qualified identifier is required to get access to an object. An exception to this is the System package, for example. This means, that in the case of System
, you can simply write Sin
which will evaluate to System.Sin
if there has not been declared an object with that name in any nearer scope.
See also: Dynamic identifiers
In many situations, identifiers can contain dynamic parts or be even replaced by strings. For example, a qualified identifier may contain a string constant like these:
System."Thread".Current
System.("Thr" + "ead").Current
To be a valid identifier, these dynamic values must evaluate to a string value.