Qore Programming Language Reference Manual
0.8.13.5
|
An expression can be any of the following (note that expressions are also recursively defined; also note that all examples are given in %new-style):
Expressions
Type | Description | Examples |
An immediate value | Qore values that can be expressed directly (see Basic Data Types and Container Data Types for more information) | |
A variable reference | Variables see also %allow-bare-refs | |
A variable declaration | Variable Declarations and Lexical Scope, Variables see also %assume-local and %new-style | |
An in-class object member reference | References to members of an object from within the class see Class Members also allow-bare-refs "%allow-bare-refs" | |
An lvalue assignment | Assigns a value to a lvalue (see Assignment Operator (=)) | |
A function call | Qore function calls (see Functions) | |
A method call | Qore object method calls (see Object Method Calls) see also %allow-bare-refs | |
An in-class method call | Qore in-class object method calls (see Object Method Calls) see also %allow-bare-refs | |
A static method call | Qore static method calls (see static_methods) | |
Expressions with operators | Use of Qore operators | |
An expression in parentheses | Use of parentheses for clarity or to specify evaluation precedence | |
A find expression | Finds a value or values in a hash of lists, such as returned by the Qore::SQL::Datasource::select() or Qore::SQL::SQLStatement::fetchColumns() method | |
A context reference (name ) | A contextual reference to the value of a key of the current row being iterated by a context, summarize, subcontext statement, or a find expression | |
A context row reference (%% ) | A contextual reference to the current row being iterated by a context, summarize, subcontext statement, or a find expression; this expression returns a hash of the current row | |
A 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 | |
A 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 | |
A call reference call | An expression executing a call reference or closure | |
An implicit argument reference ($1 ) | References an implicit argument | |
A reference to the entire implicit argument list ($$ ) | References the implicit argument list | |
An implicit index reference | Gives the list index position when implicitly iterating a list |
(
[argument_expressions...])
where
expression is True, it will evaluate and return a result expression."%"
character (as with context statements).find
result_expression in
data_expression where (
where_expression
)\
function_name()
\
class::
static_method()
\
object.method()
\
function_name ()
\
class ::
static_method ()
\
object .
method ()
OBJECT-METHOD-REFERENCE-ERROR
exception will be thrown. If the method does not exist, a METHOD-DOES-NOT-EXIST
run-time exception will be thrown.OBJECT-ALREADY-DELETED
exception to be thrown.sub ([
[type] variable1, ...]) {
[code] }
returns
keyword after the parameters:sub ([
[type] variable1, ...]) returns
return_type {
[code] }
self
and $.
member from within closures created from objects) and additionally prolongs the scope of the object for the lifetime of the closure.$
int (for a single implicit argument; int is the argument number, where 1
is the first argument)$$
(for the entire implicit argument list)$
) and either a number from 1
onwards (giving the position in the argument list, where 1
is the first element) or a double dollar sign ($$
) giving the entire implicit argument list.$#
.$#
$#
) can be used whenever a list is iterated implicitly, such as with foreach statements and the map, foldl, foldr, and select operators.