References allow for addressing other lvalues, including complex lvalue expressions, with an alias called a reference. References to lvalues are defined by placing a {\ttfamily \char`\"{}\textbackslash{}\char`\"{}} character in front of an expression that gives an lvalue, such as in the following examples\+: 
\begin{DoxyCode}
my reference $r1 = \(\backslash\)$a;
my reference $r2 = \(\backslash\)$recs[$rn].order[$on];
\end{DoxyCode}


References are especially convenient when aliasing an internal part of a complex data structure. Consider the following example (a list of records, where each record is a hash with a list of orders under the {\ttfamily \char`\"{}order\char`\"{}} key -\/ in the following example, we want to set the last record's last order's {\ttfamily \char`\"{}numberofitems\char`\"{}} key to be equal to the number of elements under the order's {\ttfamily \char`\"{}items\char`\"{}} key)\+: 
\begin{DoxyCode}
$recs[$recs.size() - 1].order[$recs[$recs.size() - 1].order.size() - 1].numberofitems = $recs[$recs.size() 
      - 1].order[$recs[$recs.size() - 1].order.size() - 1].items.size();
\end{DoxyCode}


In the above code, using references could greatly simplfy the readability of the code\+: 
\begin{DoxyCode}
my reference $lastrec = \(\backslash\)$recs[$recs.size() - 1];
my reference $lastorder = \(\backslash\)$lastrec.order[$lastrec.order.size() - 1];
$lastorder.numberofitems = $lastorder.items.size();
\end{DoxyCode}


\begin{DoxyNote}{Note}
local variables that are referenced are automatically converted to a special type of local variable that is protected by a mutual-\/exclusion thread lock so that the reference can be safely used in background threads. The lvalue represented by the local variable will exist beyond its local scope; as long as the reference to the lvalue exists, the local variable's lvalue will exist and remain valid.
\end{DoxyNote}
\begin{DoxySince}{Since}
Qore 0.\+8.\+5 universal lvalue references are supported; previously references could only be used with arguments to a function or method call or the like. As of Qore 0.\+8.\+5+, references can be used anywhere in Qore in any expression, even with references to local variables in background expressions and in closure argument lists. 
\end{DoxySince}
