An expression can be any of the following (note that expressions are also recursively defined; also note that all examples are given in \mbox{\hyperlink{parse_directives_new-style}{\%new-\/style}})\+:

{\bfseries{Expressions}}  \tabulinesep=1mm
\begin{longtabu}spread 0pt [c]{*{3}{|X[-1]}|}
\hline
{\bfseries{Type}} &{\bfseries{Description}} &{\bfseries{Examples}}  \\\cline{1-3}
An immediate value &\mbox{\hyperlink{namespace_qore}{Qore}} values that can be expressed directly (see \mbox{\hyperlink{basic_data_types}{Basic Data Types}} and \mbox{\hyperlink{container_data_types}{Container Data Types}} for more information) &
\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{keyword}{True}}

\end{DoxyCode}
 
\begin{DoxyCode}{0}
\DoxyCodeLine{1.2}

\end{DoxyCode}
 
\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{stringliteral}{"{}a string"{}}}

\end{DoxyCode}
 
\begin{DoxyCode}{0}
\DoxyCodeLine{2005-\/10-\/27}

\end{DoxyCode}
 
\begin{DoxyCode}{0}
\DoxyCodeLine{NULL}

\end{DoxyCode}
 
\begin{DoxyCode}{0}
\DoxyCodeLine{NOTHING}

\end{DoxyCode}
 
\begin{DoxyCode}{0}
\DoxyCodeLine{(\textcolor{stringliteral}{"{}key"{}} : val)}

\end{DoxyCode}
  \\\cline{1-3}
A variable reference &\mbox{\hyperlink{variables}{Variables}} ~\newline
see also \mbox{\hyperlink{parse_directives_allow-bare-refs}{\%allow-\/bare-\/refs}} &
\begin{DoxyCode}{0}
\DoxyCodeLine{var}

\end{DoxyCode}
  \\\cline{1-3}
A variable declaration &\mbox{\hyperlink{variables_variable_declarations}{Variable Declarations and Lexical Scope}}, \mbox{\hyperlink{variables}{Variables}} ~\newline
see also \mbox{\hyperlink{parse_directives_assume-local}{\%assume-\/local}} and \mbox{\hyperlink{parse_directives_new-style}{\%new-\/style}} &
\begin{DoxyCode}{0}
\DoxyCodeLine{int var}

\end{DoxyCode}
  \\\cline{1-3}
An in-\/class object member reference &References to members of an object from within the class~\newline
see \mbox{\hyperlink{qore_classes_class_members}{Class Members}} also allow-\/bare-\/refs \char`\"{}\%allow-\/bare-\/refs\char`\"{} &
\begin{DoxyCode}{0}
\DoxyCodeLine{member}

\end{DoxyCode}
  \\\cline{1-3}
An lvalue assignment &Assigns a value to a lvalue (see \mbox{\hyperlink{operators_assignment_operator}{Assignment Operator (=)}}) &
\begin{DoxyCode}{0}
\DoxyCodeLine{var = 1}

\end{DoxyCode}
 
\begin{DoxyCode}{0}
\DoxyCodeLine{(a, b, c, date) = (1, \textcolor{stringliteral}{"{}two"{}}, 3.3, 2005-\/10-\/28)}

\end{DoxyCode}
  \\\cline{1-3}
A function call &\mbox{\hyperlink{namespace_qore}{Qore}} function calls (see \mbox{\hyperlink{qore_functions}{Functions}}) &
\begin{DoxyCode}{0}
\DoxyCodeLine{calculate(var1, var2, \textcolor{stringliteral}{"{}string"{}}, 4)}

\end{DoxyCode}
  \\\cline{1-3}
A method call &\mbox{\hyperlink{namespace_qore}{Qore}} object method calls (see \mbox{\hyperlink{qore_classes_object_method_calls}{Object Method Calls}})~\newline
see also \mbox{\hyperlink{parse_directives_allow-bare-refs}{\%allow-\/bare-\/refs}} &
\begin{DoxyCode}{0}
\DoxyCodeLine{object.method(\textcolor{stringliteral}{"{}argument"{}})}

\end{DoxyCode}
  \\\cline{1-3}
An in-\/class method call &\mbox{\hyperlink{namespace_qore}{Qore}} in-\/class object method calls (see \mbox{\hyperlink{qore_classes_object_method_calls}{Object Method Calls}})~\newline
see also \mbox{\hyperlink{parse_directives_allow-bare-refs}{\%allow-\/bare-\/refs}} &
\begin{DoxyCode}{0}
\DoxyCodeLine{method(\textcolor{stringliteral}{"{}argument"{}})}

\end{DoxyCode}
  \\\cline{1-3}
A \mbox{\hyperlink{expressions_static_method_calls}{static method call}} &\mbox{\hyperlink{namespace_qore}{Qore}} static method calls (see \mbox{\hyperlink{qore_classes_static_methods}{static\+\_\+methods}}) &
\begin{DoxyCode}{0}
\DoxyCodeLine{ClassName::static\_method(\textcolor{stringliteral}{"{}argument"{}})}

\end{DoxyCode}
  \\\cline{1-3}
Expressions with operators &Use of \mbox{\hyperlink{operators}{Qore operators}} &
\begin{DoxyCode}{0}
\DoxyCodeLine{1 + 2}

\end{DoxyCode}
 
\begin{DoxyCode}{0}
\DoxyCodeLine{a || b}

\end{DoxyCode}
 
\begin{DoxyCode}{0}
\DoxyCodeLine{background my\_function()}

\end{DoxyCode}
  \\\cline{1-3}
An expression in parentheses &Use of parentheses for clarity or to specify evaluation precedence &
\begin{DoxyCode}{0}
\DoxyCodeLine{(3 * (2 + a))}

\end{DoxyCode}
  \\\cline{1-3}
A \mbox{\hyperlink{expressions_find}{find expression}} &Finds a value or values in a hash of lists, such as returned by the \mbox{\hyperlink{class_qore_1_1_s_q_l_1_1_datasource_a05b1d0d126d815b2d7578e5ce8b9a0de}{Qore\+::\+SQL\+::\+Datasource\+::select()}} or \mbox{\hyperlink{class_qore_1_1_s_q_l_1_1_s_q_l_statement_a7ec66c1e186aac00034b27015adf8c1c}{Qore\+::\+SQL\+::\+SQLStatement\+::fetch\+Columns()}} method &
\begin{DoxyCode}{0}
\DoxyCodeLine{find \%name, \%id \textcolor{keywordflow}{in} data where (\%name =\string~ /Smith/)}

\end{DoxyCode}
  \\\cline{1-3}
A context reference ({\ttfamily name}) &A contextual reference to the value of a key of the current row being iterated by a \mbox{\hyperlink{statements_context}{context}}, \mbox{\hyperlink{statements_summarize}{summarize}}, \mbox{\hyperlink{statements_subcontext}{subcontext}} statement, or a \mbox{\hyperlink{expressions_find}{find expression}} &
\begin{DoxyCode}{0}
\DoxyCodeLine{\%name}

\end{DoxyCode}
  \\\cline{1-3}
A context row reference ({\ttfamily \%\%}) &A contextual reference to the current row being iterated by a \mbox{\hyperlink{statements_context}{context}}, \mbox{\hyperlink{statements_summarize}{summarize}}, \mbox{\hyperlink{statements_subcontext}{subcontext}} statement, or a \mbox{\hyperlink{expressions_find}{find expression}}; this expression returns a hash of the current row &
\begin{DoxyCode}{0}
\DoxyCodeLine{\%\%}

\end{DoxyCode}
  \\\cline{1-3}
A \mbox{\hyperlink{expressions_call_reference}{call reference}} &A reference to a function or object method call (similar to a function pointer in C or C++). Function references are resolved in the second phase of parsing (commit phase), while object method references are resolved at run-\/time &
\begin{DoxyCode}{0}
\DoxyCodeLine{\(\backslash\)function\_call()}

\end{DoxyCode}
 
\begin{DoxyCode}{0}
\DoxyCodeLine{\(\backslash\)object\_expression.method\_name()}

\end{DoxyCode}
  \\\cline{1-3}
A \mbox{\hyperlink{expressions_closure}{closure}} &An anonymous function used a value; technically a closure must have at least one bound variable, but in Qore a closure is any function used as a value, whether or not it encloses local variables from the scope in which it was created or not &
\begin{DoxyCode}{0}
\DoxyCodeLine{string sub (string a) \{ \textcolor{keywordflow}{return} a + b; \}}

\end{DoxyCode}
  \\\cline{1-3}
A call reference call &An expression executing a \mbox{\hyperlink{expressions_call_reference}{call reference}} or \mbox{\hyperlink{expressions_closure}{closure}} &
\begin{DoxyCode}{0}
\DoxyCodeLine{my\_closure(arg1, arg2)}

\end{DoxyCode}
  \\\cline{1-3}
An \mbox{\hyperlink{expressions_implicit_arguments}{implicit argument}} reference ({\ttfamily \$1}) &References an implicit argument &
\begin{DoxyCode}{0}
\DoxyCodeLine{\$1}

\end{DoxyCode}
  \\\cline{1-3}
A reference to the entire \mbox{\hyperlink{expressions_implicit_arguments}{implicit argument}} list ({\ttfamily \$\$}) &References the implicit argument list &
\begin{DoxyCode}{0}
\DoxyCodeLine{\$\$}

\end{DoxyCode}
  \\\cline{1-3}
An \mbox{\hyperlink{expressions_implicit_index}{implicit index}} reference &Gives the list index position when implicitly iterating a list &
\begin{DoxyCode}{0}
\DoxyCodeLine{\$\textcolor{comment}{\#}}

\end{DoxyCode}
  \\\cline{1-3}
\end{longtabu}


\DoxyHorRuler{0}
 \hypertarget{expressions_static_method_calls}{}\doxysection{Static Method Calls}\label{expressions_static_method_calls}
\begin{DoxyParagraph}{Synopsis}
Calls to static class methods are made by giving the class name followed by two colons and then the method name. The method name must be implemented and accessible (i.\+e. not private and accessed outside the class) somewhere within the class hierarchy and must be static or a parse exception will occur.
\end{DoxyParagraph}
\begin{DoxyParagraph}{Syntax}
{\itshape class\+\_\+name\+::method\+\_\+name} {\ttfamily (}{\itshape \mbox{[}argument\+\_\+expressions...\mbox{]}}{\ttfamily )}
\end{DoxyParagraph}
\begin{DoxyParagraph}{Description}
{\itshape class\+\_\+name} ~\newline
 The name of the class implementing the static method.~\newline
~\newline
 {\itshape method\+\_\+name} ~\newline
 The name of the static method to call.~\newline
~\newline
 {\itshape \mbox{[}argument\+\_\+expressions...\mbox{]}}~\newline
 Expressions passing arguments to the static method.
\end{DoxyParagraph}
\begin{DoxyParagraph}{Example}

\begin{DoxyCode}{0}
\DoxyCodeLine{TimeZone::setRegion(\textcolor{stringliteral}{"{}Europe/Prague"{}});}

\end{DoxyCode}

\end{DoxyParagraph}
\DoxyHorRuler{0}
 \hypertarget{expressions_find}{}\doxysection{Find Expressions}\label{expressions_find}
\begin{DoxyParagraph}{Synopsis}
The find expression can be used to quickly find data in a hash of lists (such as a query result set returned by the \mbox{\hyperlink{class_qore_1_1_s_q_l_1_1_datasource_a05b1d0d126d815b2d7578e5ce8b9a0de}{Qore\+::\+SQL\+::\+Datasource\+::select()}} or \mbox{\hyperlink{class_qore_1_1_s_q_l_1_1_s_q_l_statement_a7ec66c1e186aac00034b27015adf8c1c}{Qore\+::\+SQL\+::\+SQLStatement\+::fetch\+Columns()}} methods). The find expression will loop through a data structure, and for each element in the structure where the {\ttfamily where} expression is \mbox{\hyperlink{basic_data_types_True}{True}}, it will evaluate and return a result expression.~\newline
~\newline
 If the {\itshape where\+\_\+expression} only is \mbox{\hyperlink{basic_data_types_True}{True}} for one element in the list, it will return the result of evaluating the result expression directly, otherwise if the {\itshape where\+\_\+expression} is \mbox{\hyperlink{basic_data_types_True}{True}} more than once, then a list of the results of evaluting the result expression for each element is returned.~\newline
~\newline
 In each expression in the find expression, column values can be referred to by preceding the name with a {\ttfamily \char`\"{}\%\char`\"{}} character (as with \mbox{\hyperlink{statements_context}{context statements}}).
\end{DoxyParagraph}
\begin{DoxyParagraph}{Syntax}
{\ttfamily {\bfseries{find}}} {\itshape result\+\_\+expression} {\ttfamily {\bfseries{in}}} {\itshape data\+\_\+expression} {\ttfamily {\bfseries{where}} (}{\itshape where\+\_\+expression{\ttfamily })}
\end{DoxyParagraph}
\begin{DoxyParagraph}{Description}
{\itshape result\+\_\+expression} ~\newline
 This expression will be evaluated and returned when the {\itshape where\+\_\+expression} evaluates to \mbox{\hyperlink{basic_data_types_True}{True}}.~\newline
~\newline
 {\itshape data\+\_\+expression} ~\newline
 This expression must evaluate to a hash of lists, so that the internal context can be set up for the find loop.~\newline
~\newline
 {\itshape where\+\_\+expression} ~\newline
 This expression will be evaluated for each row in the {\itshape data\+\_\+expression}. Each time it evaluates to \mbox{\hyperlink{basic_data_types_True}{True}}, the {\itshape result\+\_\+expression} will be evaulated and used for the return value for the find expression.
\end{DoxyParagraph}
\begin{DoxyParagraph}{Example}

\begin{DoxyCode}{0}
\DoxyCodeLine{rlist = find \%fname, \%id \textcolor{keywordflow}{in} data where (\%lname =\string~ /\string^Smith/);}

\end{DoxyCode}

\end{DoxyParagraph}
\begin{DoxySeeAlso}{See also}

\begin{DoxyItemize}
\item context
\item summarize
\item subcontext
\end{DoxyItemize}
\end{DoxySeeAlso}
\DoxyHorRuler{0}
 \hypertarget{expressions_call_reference}{}\doxysection{Call References}\label{expressions_call_reference}
\begin{DoxyParagraph}{Synopsis}
References to functions or object methods are called call references. A call reference can be used like a function pointer; a call reference is a Qore data type that can be returned by functions or methods or assigned to variables.~\newline
~\newline
 Note that the empty parentheses after the call are required to identify the expression as a call reference.
\end{DoxyParagraph}
\begin{DoxyParagraph}{Syntax}
{\ttfamily \textbackslash{}}{\itshape function\+\_\+name}{\ttfamily ()}~\newline
 {\ttfamily \textbackslash{}}{\itshape class}{\ttfamily \+::}{\itshape static\+\_\+method}{\ttfamily ()}~\newline
 {\ttfamily \textbackslash{}}{\itshape object.\+method}{\ttfamily ()}
\end{DoxyParagraph}
\begin{DoxyParagraph}{Description}
{\ttfamily \textbackslash{}} {\itshape function\+\_\+name} {\ttfamily ()}~\newline
 This makes a call reference to a function. Call references to functions are resolved at parse time; if the function does not exist a parse exception will be thrown.~\newline
~\newline
 {\ttfamily \textbackslash{}} {\itshape class} {\ttfamily \+::} {\itshape static\+\_\+method} {\ttfamily ()}~\newline
 This makes a call reference to a static method. Call references to static methods are resolved at parse time; if the static method does not exist a parse exception will be thrown.~\newline
~\newline
 {\ttfamily \textbackslash{}} {\itshape object} {\ttfamily .} {\itshape method} {\ttfamily ()}~\newline

\begin{DoxyItemize}
\item {\itshape object\+:} can be any valid Qore expression that evaluates to an object
\item {\itshape method\+:} must be an unquoted string (see example below) and must represent a valid method name of the object\textquotesingle{}s class.
\end{DoxyItemize}This makes a call reference to an object method call, binding the object and the method in the call reference. Call references to object methods are executed and resolved at run time; if the object expression does not evaluate to an object at run-\/time, an {\ttfamily OBJECT-\/\+METHOD-\/\+REFERENCE-\/\+ERROR} exception will be thrown. If the method does not exist, a {\ttfamily METHOD-\/\+DOES-\/\+NOT-\/\+EXIST} run-\/time exception will be thrown.~\newline
~\newline
 When called, a call reference to an object method will be executed in the context of the object originally referenced. Object method call references do not prolong the lifetime of an object; if the object is deleted (for example, by going out of scope), then if called the call reference will cause an {\ttfamily OBJECT-\/\+ALREADY-\/\+DELETED} exception to be thrown.
\end{DoxyParagraph}
\begin{DoxyParagraph}{Example}

\begin{DoxyCode}{0}
\DoxyCodeLine{code c = \(\backslash\)printf(); }

\end{DoxyCode}
 
\begin{DoxyCode}{0}
\DoxyCodeLine{code c = \(\backslash\)MyClass::method(); }

\end{DoxyCode}
 
\begin{DoxyCode}{0}
\DoxyCodeLine{code c = \(\backslash\)obj.method(); }

\end{DoxyCode}

\end{DoxyParagraph}
\begin{DoxyNote}{Note}

\begin{DoxyItemize}
\item The backslash at the beginning and the empty parentheses at the end; these are required when specifying a call reference.
\item call reference is a code data type; see \mbox{\hyperlink{code_data_types_callref_type}{Call Reference Type}} for more information
\end{DoxyItemize}
\end{DoxyNote}
\DoxyHorRuler{0}
 \hypertarget{expressions_closure}{}\doxysection{Closures}\label{expressions_closure}
\begin{DoxyParagraph}{Synopsis}
A closure is an anonymous function used as a value. Closures can be returned from functions or methods, assigned to variables, or passed as arguments to other functions.
\end{DoxyParagraph}
\begin{DoxyParagraph}{Syntax}
\mbox{[}{\bfseries{\mbox{\hyperlink{deprecated}{deprecated}}}}\mbox{]} \mbox{[}{\bfseries{\mbox{\hyperlink{qore_classes_public_inheritance}{public}}}}\mbox{]} \mbox{[}{\bfseries{\mbox{\hyperlink{threading_synchronized}{synchronized}}}}\mbox{]} {\itshape \mbox{\hyperlink{data_type_declarations}{\mbox{[}return\+\_\+type\mbox{]}}}} {\ttfamily {\bfseries{sub}} (\mbox{[}}{\itshape \mbox{\hyperlink{data_type_declarations}{\mbox{[}type\mbox{]}}} variable1}{\ttfamily , ...\mbox{]}) \{} {\itshape \mbox{[}code\mbox{]}} {\ttfamily \}}~\newline
~\newline
 or the alternate (deprecated) syntax with the {\ttfamily returns} keyword after the parameters\+:~\newline
~\newline
 \mbox{[}{\bfseries{\mbox{\hyperlink{deprecated}{deprecated}}}}\mbox{]} \mbox{[}{\bfseries{\mbox{\hyperlink{qore_classes_public_inheritance}{public}}}}\mbox{]} \mbox{[}{\bfseries{\mbox{\hyperlink{threading_synchronized}{synchronized}}}}\mbox{]} {\ttfamily {\bfseries{sub}} (\mbox{[}} {\itshape \mbox{\hyperlink{data_type_declarations}{\mbox{[}type\mbox{]}}} variable1}{\ttfamily , ...\mbox{]}) {\bfseries{returns}}} {\itshape \mbox{\hyperlink{data_type_declarations}{return\+\_\+type}}} {\ttfamily \{} {\itshape \mbox{[}code\mbox{]}} {\ttfamily \}}
\end{DoxyParagraph}
\begin{DoxyParagraph}{Description}
Closures encapsulate the state and value of local variables of the outer code block referenced from within the closure when the closure is created. Whenever local variables are bound within a closure, these variables are subject to concurrent thread access protection (locking) just as with global variables, in order to allow closures to be used in any context without restriction and to preseve thread-\/safety regarding bound local variables.~\newline
~\newline
 Note that returning a closure from within an object method encapsulates the state of the object as well (it\textquotesingle{}s legal to refer to {\ttfamily self} and {\ttfamily \$.}{\itshape member} from within closures created from objects) and additionally prolongs the scope of the object for the lifetime of the closure.~\newline
~\newline
 Note that parameter and return types are required when the \mbox{\hyperlink{group__parse__options_ga66847391bb96dac88c3fee210720bbb3}{Qore\+::\+PO\+\_\+\+REQUIRE\+\_\+\+TYPES}} or \mbox{\hyperlink{group__parse__options_ga196e048def21cb147b21a4871c4e9b29}{Qore\+::\+PO\+\_\+\+REQUIRE\+\_\+\+PROTOTYPES}} parse options are set.
\end{DoxyParagraph}
\begin{DoxyParagraph}{Example}

\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{comment}{\# if b is a local variable in the function where the closure is created}}
\DoxyCodeLine{\textcolor{comment}{\# then b will be bound to the closure when the closure is created}}
\DoxyCodeLine{code closure = int sub (int a) \{ \textcolor{keywordflow}{return} a + b; \};}

\end{DoxyCode}

\end{DoxyParagraph}
\begin{DoxyNote}{Note}
closure is a code data type; see \mbox{\hyperlink{code_data_types_closure_type}{Closure Type}} for more information
\end{DoxyNote}
\DoxyHorRuler{0}
 \hypertarget{expressions_implicit_arguments}{}\doxysection{Implicit Argument References}\label{expressions_implicit_arguments}
\begin{DoxyParagraph}{Synopsis}
Implicit arguments are arguments not captured by parameter variables as well as automatic arguments in list-\/processing operator expressions. A special syntax to reference these arguments is documented here.
\end{DoxyParagraph}
\begin{DoxyParagraph}{Syntax}
{\ttfamily \$}{\itshape int} (for a single implicit argument; {\itshape int} is the argument number, where {\ttfamily 1} is the first argument)~\newline
 {\ttfamily \$\$} (for the entire implicit argument list)
\end{DoxyParagraph}
\begin{DoxyParagraph}{Description}
Implicit arguments can be directly referenced using the dollar sign ({\ttfamily \$}) and either a number from {\ttfamily 1} onwards (giving the position in the argument list, where {\ttfamily 1} is the first element) or a double dollar sign ({\ttfamily \$\$}) giving the entire implicit argument list.~\newline
~\newline
 For unassigned arguments to functions or methods, this syntax supplements the automatic argv variable holding all function arguments not assigned to parameter variables.~\newline
~\newline
 This syntax is particularly useful when writing expressions for the \mbox{\hyperlink{operators_map}{map}}, \mbox{\hyperlink{operators_foldl}{foldl}}, \mbox{\hyperlink{operators_foldr}{foldr}}, and \mbox{\hyperlink{operators_select}{select}} operators, where implicit argument references are the only way the operator expressions can reference the current list values that are populated as implicit arguments as the operators traverse the list.
\end{DoxyParagraph}
\begin{DoxyParagraph}{Example}

\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{comment}{\# extract a list of even numbers from a list}}
\DoxyCodeLine{list l = select list, !(\$1 \% 2);}

\end{DoxyCode}

\end{DoxyParagraph}
\DoxyHorRuler{0}
 \hypertarget{expressions_implicit_index}{}\doxysection{Implicit Index}\label{expressions_implicit_index}
\begin{DoxyParagraph}{Synopsis}
The current list index position when implicitly iterating through lists can be referenced using the implicit index reference characters\+: {\ttfamily \$\#}.
\end{DoxyParagraph}
\begin{DoxyParagraph}{Syntax}
{\ttfamily \$\#}
\end{DoxyParagraph}
\begin{DoxyParagraph}{Description}
The implicit index reference expression ({\ttfamily \$\#}) can be used whenever a list is iterated implicitly, such as with \mbox{\hyperlink{statements_foreach}{foreach statements}} and the \mbox{\hyperlink{operators_map}{map}}, \mbox{\hyperlink{operators_foldl}{foldl}}, \mbox{\hyperlink{operators_foldr}{foldr}}, and \mbox{\hyperlink{operators_select}{select}} operators.
\end{DoxyParagraph}
\begin{DoxyParagraph}{Example}

\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{comment}{\# create a list of indexes with negative values}}
\DoxyCodeLine{list l = map \$\textcolor{comment}{\#, list, (\$1 < 0);}}

\end{DoxyCode}
 
\end{DoxyParagraph}
