Identifier
Release: |
4.6 • 5.0 • 5.1 • 5.2 • 5.3 • 5.4 • 6.0 • 6.1 • 6.2 • 6.3 • 6.4 • 6.5 |
---|
An identifier is a name that is used to refer to an Analytica object or to a (temporary) value.
- Each object in Analytica's global name space has a unique identifier. This includes all nodes in your model, built-in functions, system variables, attributes, classes, typescript commands, etc.
- Inside a Function definition, the identifiers of pass-by-value parameters refer to the value that was passed by the caller.
- In an expression, a Local identifier that is declared via the Local..Do or For..Do constructs refers to the value that was computed on the right-hand side of the
:=
when the local was declared, or to values subsequently assigned to the local. - Inside a Function definition, the parameters declared with a class name (
Index
Object
,Variable
,Variable
,Class
, orAttribute
) refer to objects. The identifier of the parameter is, in general, different from the identifier of the underlying object, but the parameter identifier can be used in the Definition expression. - In an expression, local identifiers declared using LocalIndex or LocalAlias constructs name objects. In general, the identifier of the local can be different from the identifier of the underlying object.
Although some identifiers refer to objects while other identifiers refer to values, the rules for what qualifies as a legal identifier name are the same in both cases. Thus, you cannot tell from the identifier whether it names an object or a value. Many people adopt a stylistic convention of capitalizing identifiers that refer to objects, such as names of global variable and indexes, and using lower case for value identifiers.
Underlying identifier of an object
Every object has an identifier has its own identifier. You can access this underlying identifier using the expression
Identifier Of Time
returns "Time".
In some cases, the identifier you are using to refer to the object might be different from the underlying identifier. This occurs, for example, if you pass the object as a parameter. The following illustrates:
Function NameOfIndex( I : Index )
- Definition:
Identifier of I
Now call:
NameOfIndex( Time )
The result is "Time"
, not "I"
.
When an identifier names a value, you cannot access its identifier via an expression.
Local x := 4+5 Do (Identifier of X)
→ Error: 'Identifier Of x' does not exist.
Legal names for Identifiers
Identifiers are case-insensitive. Thus, Profit
, profit
, PROFIT
and prOFIt
are all the same identifier. In addition they are accent sensitive, and Unicode normalization insensitive.
Identifiers can start with letters (Unicode categories Ll, Lm, Lo, Lt, Lu) and "letter numbers" (Unicode category Nl). Some built-in or internal identifiers may start with an underscore, but user identifiers cannot. After the first character, subsequent characters include all the starting categories as well digits, underscores and Unicode categories Mc, Mn, Nd and Pc (spacing marks, non-spacing marks, decimal numbers and connector punctuation). These categories capture a natural sense of words in pretty much any language. In general, spaces and punctuation characters are disallowed in identifiers (but may appear in titles).
You can use an Identifier that does not abide by these rules by surrounding it in backquotes. A backquoted identifier can contain pretty much any printable character except backquotes, newlines and unprintable control characters. If the characters excluding the surrounding backquotes qualify as a legal identifier without the backquotes, then the identifier with or without the backquotes are considered the same.
The following are examples of legal (allowed) identifiers:
- x
- Annual_Revenue
- Health_damage
- Revenue_by_product_category
- N14compliance
- Rank17
- A_b_c_d
- Te1261540435
- Disminución_diaria
- θ
- Απόσταση
- 升值率高于通货膨胀率
- Rennslishraði
- ความหนาแน่นของฟอเรสต์
- जनसंख्या_वृद्धि_दर
- `n!`
- `+`
- `Emission reduction ($)`
The following are examples of non-legal names for identifiers(when not backquoted):
- A&B
- n!
- 4x
- _x --- Starting with underscore is reserved for system use
Note:
Ingreso
,INGRESO
and`Ingreso`
are all the same identifier (case-insensitive, backquote insensitive when legal).Ingreso
andIngresó
are different identifiers (accent-sensitive).Emission_reduction
and`Emission reduction`
are different identifiers (space and underscore are different)
Generating an identifier from the title
When you enter a title for an object, Analytica will usually automatically generate an identifier from the title, and may ask you if you want to rename it (the exact behavior can be configured on the Preference Dialog). It does this by replacing spaces and punctuation with underscores, converting Chinese character to their Pinyin romanizations, appending digits to the end to ensure uniqueness, etc. One "gotcha" to watch out for is the appending of digits when an object already exists with the same name. So, for example, if you title a variable NPV, the automatically generated Identifier is NPV1, which isn't obvious when you are viewing only the title on a diagram. In a Definition of another variable, you will need to use NPV1 in your expression. The 1 appends here because the name NPV is already used by the built-in function.
One preference setting is the length of the identifier, which controls the maximum character limit for an identifier generated from a title. This defaults to 20 until you change it. You can increase it to allow for longer generated titles. It does not limit the length when you edit the Identifier
attribute directly. Excessively lengthy identifiers can detract from expression readability, but you may find a larger length to be convenient.
{{{3}}}
Toggle between Title and Identifier views
In most Analytica windows, including diagrams, tables, and the outliner, you can toggle between viewing Identifiers or Titles by pressing Ctrl+Y (on toggling Show by identifier on the Object menu). This shortcut becomes second-nature to seasoned model builders.
History
The set of legal identifiers was greatly enlarged in the Analytica 6.4 release to include:
- Non-english characters
- Identifiers longer than 20 characters.
- Backquoted identifiers for arbitrary text
- Removed the generation of pinyin identifiers from Asian language titles (Chinese, Japanese, Korean), since those character sets are now allowed.
To compare the differences, use the release bar at the top of this page to 6.3 or earlier or 6.4 or later.
Enable comment auto-refresher