LocalAlias..Do
Requires Analytica 4.2
LocalAlias «x» := «expr» Do «body»
Alias «x» := «expr» Do «body»
The local variable declarations are used to create a local variable, «x», that will be used to hold a handle to an Analytica object, such that wherever the identifier «x» is used within the «body» expression, «x» serves as an alias of the object pointed to by the handle.
The expression «expr» is evaluated, and would most commonly return a Handle when this declaration is used.
These are useful when implementing Meta-inference algorithms.
Examples
Using a local alias, you can shorten an expression that uses the value of a variable that has a very long identifier. When doing this, there are two notable uses:
LocalAlias x := Handle(A) Do «body» LocalAlias x := Handle(A,asIndex:True) Do «body»
In both cases, x serves as an alias of A everywhere in «body». If we were to copy the «body» expression, substituting the identifier A for the identifier x, we would obtain the same result as with the first case. The second case, where asIndex:true is declared, makes x serve as an alias to the index A in the case where A's value contains a self-index. The distinction here is tha that when x is used in a value context within «body», the IndexValue(A) is used, rather than the Mid(A) or Sample(A) value.
These two uses of LocalAlias..Do can be used to shorten an expression that makes repeated use of a variable with a long identifier. For example:
LocalAlias x := Handle(Budgetary_allocations); LocalAlias L := Handle(Allocations_Category,asIndex:True); (x[L='daily']*365 + x[L='weekly']*52 + x[L='monthly']*12) * x[L='frequency of request']
Enable comment auto-refresher