next up previous index
Next: Implementation of Expressions Up: Expressions Previous: Operators for Opus Expressions   Index


Equivalence of Variable Names and Expressions

Two variable names consisting of an attribute, a dataset-qualified attribute, or a fully-qualified attribute are of course equal if the component strings are equal.

Two expressions are equal if their defining strings are identical, ignoring spaces. Thus these two expressions are equivalent:

urbansim.gridcell.population+1
urbansim.gridcell.population + 1

However, two textually different expressions are not equivalent, even if they are algebraically equal. For example, 1 + urbansim.gridcell.population is different from the previous expressions. In many cases this doesn't matter. Reasons it may matter are: (1) if the resulting value uses a lot of memory or takes a long time to compute, having a second copy of the value will waste memory or computation time; and (2) if the variable defined by the expression is used in a specification, you could inadvertently end up with two variables. For this reason, good programming practice is to have just one place in a file that defines the expression, including an alias. Elsewhere use the alias.


next up previous index
Next: Implementation of Expressions Up: Expressions Previous: Operators for Opus Expressions   Index
info (at) urbansim.org