Qore Programming Language Reference Manual
0.8.11.1
|
The following table lists all Qore operators in order of precedence, starting with the highest precedence. The lower the precedence number, the higher the precedence, therefore the operators with precedence level 1 ("{}"
, "[]"
, "."
) have the highest precedence of all Qore operators. The precedence levels in Qore are roughly equal to the precedence levels of C language operators. To explicitly specify the precedence for expression evaluation, use parentheses ()
.
Operators
$a += 5
is a thread-atomic action, but $a += $b–
is not atomic, but rather made up of two atomic actions.`
shell_command`
Arguments Processed by ``
Argument | Returns | Processing |
unquoted string shell_command | string | The shell command will be executed and the stdout is returned as a string |
BACKQUOTE-ERROR | An error occurred in fork() or creating the output pipe |
{
expression }
Arguments Processed by {}
Argument | Processing |
container_expression | This expression must evaluate to a hash or an object; if not, the operator returns no value (NOTHING) |
expression | - list: if the expression evaluates to a list, then a slice of the hash or object is returned as a hash containing keys given in the list that are present in the hash or object. If the key as given in the list (converted to a string if necessary) is not present in the hash or object, then it is also not present in the hash returned; of none of the given keys exist in the hash, an empty hash is returned. - anything other than list: the expression is converted to a string (if necessary); the value of the hash key corresponding to this string will be returned; if the key or member does not exist, then no value is returned |
PRIVATE-MEMBER | Attempt to access a private member outside the class |
.
identifier .
method_name
([args ...])
.
expression Arguments Processed by . (hash key or object member literal dereference)
Argument | Processing |
hash_or_object_expression | This expression must evaluate to a hash or an object; if not, then the operator returns no value |
identifier | An unquoted string taken as the literal name of the hash key or object member. If no such key exists, then no value is returned. In order to use hash keys that are not valid Qore identifiers, please use the {} operator. If the member is a private member and access is made outside the class, a run-time exception will be thrown. Also note that constants or static class member names will not be resolved, in this case the string given is used as the literal name of the hash key or object member |
Arguments Processed by . (object method call)
Argument | Processing |
object_expression | The object_expression must evaluate to an object or a run-time exception is thrown |
method_name([ args]) | If the method does not exist in the class a run-time exception is thrown. Otherwise the method is called with any optional arguments given and the return value of the method is returned. |
Arguments Processed by . (hash key or object member expression dereference)
Argument | Processing |
hash_or_object_expression | This expression must evaluate to a hash or an object; if not, then the operator returns no value |
expression | - list: if the expression evaluates to a list, then a slice of the hash or object is returned as a hash containing keys given in the list that are present in the hash or object. If the key as given in the list (converted to a string if necessary) is not present in the hash or object, then it is also not present in the hash returned; of none of the given keys exist in the hash, an empty hash is returned. - anything other than list: the expression is converted to a string (if necessary); the value of the hash key corresponding to this string will be returned; if the key or member does not exist, then no value is returned |
PRIVATE-MEMBER | Attempt to access a private member outside the class |
METHOD-DOES-NOT-EXIST | Attempt to access a method not defined for this class |
METHOD-IS-PRIVATE | Attempt to access a private method from outside the class |
BASE-CLASS-IS-PRIVATE | Attempt to access a method of a privately-inherited base class from outside the class |
OBJECT-METHOD-EVAL-ON-NON-OBJECT | Attempt to execute a method on a non-object |
[
offset_expression
] string_expression[
offset_expression
] binary_expression[
offset_expression
]Arguments Processed by []
Argument | Processing |
list_expression | If the expression evaluates to a list, then the offset_expression will be used to return the given element from the list |
string_expression | If the expression evaluates to a string, then the offset_expression will be used to return the given character from the list; note that multi-byte characters with UTF-8 are properly respected with this operator |
binary_expression | If the expression evaluates to a binary, then the offset_expression will be used to return the integer value of the byte given from the binary object |
offset_expression | The expression is evaluated and converted to an integer if necessary. Then the value of the given element given is returned according to the type of the first expression (as listed above; elements start at position 0) |
This operator does not throw any exceptions; if the first expression does not evaluate to either a list, string, or binary, then no value (NOTHING) is returned.
++
lvalueArguments Processed by ++ (pre-increement)
Argument | Processing |
Float | increments lvalue and returns the result |
Integer (or any other type) | First converts the value of lvalue to an integer if necessary, then increments lvalue and returns the result |
This operator does not throw any exceptions.
++
Arguments Processed by ++ (post-increment)
Argument | Processing |
Float | saves the value of the lvalue as the result, then increments lvalue, then returns the saved original value of lvalue |
Integer (or any other type) | saves the value of the lvalue as the result, then converts the value of lvalue to an integer if necessary and increments it, then returns the saved original value of lvalue |
This operator does not throw any exceptions.
–
lvalueArguments Processed by – (pre-decrement)
Argument | Processing |
Float | increments lvalue and returns the result |
Integer (or any other type) | First converts the value of lvalue to an integer if necessary, then increments lvalue and returns the result |
This operator does not throw any exceptions.
–
Arguments Processed by – (post-decrement)
Argument | Processing |
Float | saves the value of the lvalue as the result, then decrements lvalue, then returns the saved original value of lvalue |
Integer (or any other type) | saves the value of the lvalue as the result, then converts the value of lvalue to an integer if necessary and decrements it, then returns the saved original value of lvalue |
This operator does not throw any exceptions.
new
class_identifier(
constructor_args ...)
Arguments Processed by new
Argument | Processing |
class_identifier | The class_identifier must be an existing class name; if so, the operator instantiates an object of this class, executes the constructor for the class (if any exists, along with any base class constructors, if applicable) on the new object, and returns the object (for constructor execution order in an inherited class, see Class Inheritance). If an exception is thrown in the constructor, the object is deleted immediately. |
background
expression Arguments Processed by background
Argument | Processing |
expression | The expression given as an argument will be executed in a new thread. The TID of the new thread will be returned as the return value of the operator |
THREAD-CREATION-FAILURE | If the thread table is full or if the operating system returns an error while starting the thread, this exception is thrown |
delete
lvalue_expression This operator does not throw any exceptions, however exceptions could be thrown in an object's destructor method when deleted by this operator.
remove
lvalue_expression This operator does not throw any exceptions, however exception could be thrown in an object's destructor if it goes out of scope due to the action of this operator.
cast
<class_identifier>(
object_expression)
Arguments Processed by cast<>()
Argument | Processing |
class_identifier | This must be a literal unquoted string giving a class name or a namespace-qualified path to a class (ex: Namespace::MyClass ) |
object_expression | This must be an expression that evaluates to an object that can be cast to the given class; this is mostly useful at parse time to avoid non-existent-method-call warnings |
RUNTIME-CAST-ERROR | The expression given does not evaluate to an object that can be cast to the given class |
!
expressionArguments Processed by !
Argument | Processing |
expression | The expression is evaluated and converted to a bool, if necessary. Then the value is logically reversed (True becomes False, False becomes True) |
This operator does not throw any exceptions.
~
expressionArguments Processed by ~
Argument | Processing |
expression | The argument is converted to an integer (if necessary), and bitwise negation is performed on the argument (ex: 666 & ~27 results in 640 ) |
This operator does not throw any exceptions
Arguments Processed by - (unary minus)
Argument | Processing |
Float | Gives the negative of its argument as a Float (ex: -(-1.1) = 1.1, -(1.1) = -1.1 |
Integer | Gives the negative of its argument as an Integer (ex: -(-1) = 1, -(1) = -1 |
This operator does not throw any exceptions
shift
lvalue Arguments Processed by shift
Argument | Processing |
lvalue | Returns the first element of the list, and the list is modified by having the first element removed from the list. If the lvalue is not a list, no action is performed and the operator returns no value (NOTHING) |
This operator does not throw any exceptions.
pop
lvalue Arguments Processed by pop
Argument | Processing |
lvalue | Returns the last element of the list, and the list is modified, having the last element removed from the list. If the lvalue is not a list, no action is performed and the operator returns no value (NOTHING) |
This operator does not throw any exceptions.
'\n'
or '\r\n'
) from a string, or each string element in a list, or each hash key value in a hash (if the value is a string) and returns the number of characters removed.chomp
lvalueArguments Processed by chomp
Argument | Processing |
lvalue (String) | Removes any EOL characters from a string and returns the number of characters removed. |
lvalue (List) | Removes any EOL characters from each string element of the list passed and returns the number of characters removed. |
lvalue (Hash) | Removes any EOL characters from each hash key's value (where the value is a string) and returns the number of characters removed. |
This operator does not throw any exceptions.
' '
(blank spaces), '\n'
, '\r'
, '\t'
, '\v'
(vertical tab, ASCII 11), and '\0'
(null character).trim
lvalue Arguments Processed by trim
Argument | Processing |
lvalue (String) | Removes whitespace characters from the beginning and end of a string and returns the value processed. |
lvalue (List) | Removes whitespace characters from the beginning and end of each string element of the list passed and returns the list. |
lvalue (Hash) | Removes whitespace characters from the beginning and end of each string value of the hash passed and returns the hash. |
This operator does not throw any exceptions.
map
operator iterates the object by calling AbstractIterator::next(), and the implicit argument $1
in the map_expression and any optional select_expression is the value returned by AbstractIterator::getValue().map
map_expression, list_expression [, select_expression]Arguments Processed by map
Argument | Processing |
map_expression | The expression to map on the list; the implicit argument $1 represents the current element being processed (or the object itself if the map operator is iterating an object inheriting the AbstractIterator class). |
list_expression | The data to process; if this is not a list then the map_expression is run on the single argument passed, unless the map_expression is an object inheriting the AbstractIterator class; in this case the map operator iterates the object by calling AbstractIterator::next() |
[select_expression] | An optional expression than can be used to filter out elements of the list before the map expression is applied; if this expression evaluates to False on an element, then the element will be skipped and the map_expression will not be applied on that element. |
This operator does not throw any exceptions (however note that exceptions could be thrown by expressions executed by this operator).
foldl
operator iterates the object by calling AbstractIterator::next(), and the implicit arguments $1
and $2
in expression are the container values returned by AbstractBidirectionalIterator::getValue(). If the list_expression does not evaluate to a list or an object inheriting AbstractIterator, then the evaluated argument is returned immediately with no processing by the fold expression.foldl
expression, list_expression foldl
expression returns 5
foldl
expression joins a list with ", "
or returns a single argument (if the second operand is not a list) Arguments Processed by foldl
Argument | Processing |
expression | The expression to fold on the list; the implicit argument $1 represents the result of the last operation (or the first element in the list when beginning the fold), and $2 represents the next element of the list. |
list_expression | The list, AbstractIterator object or other value according to the rules above to process |
This operator does not throw any exceptions (however note that exceptions could be thrown by expressions executed by this operator).
foldr
operator iterates the object by calling AbstractBidirectionalIterator::prev(), and the implicit arguments $1
and $2
in expression are the container values returned by AbstractBidirectionalIterator::getValue(). If the list_expression does not evaluate to a list or an object inheriting AbstractBidirectionalIterator, then the evaluated argument is returned immediately with no processing by the fold expression.foldr
expression, list_expression Arguments Processed by foldr
Argument | Processing |
expression | The expression to fold on the list; the implicit argument $1 represents the result of the last operation (or the last element in the list when beginning the fold), and $2 represents the next element of the list in reverse order. |
list_expression | The list, AbstractIterator object or other value according to the rules above to process |
This operator does not throw any exceptions (however note that exceptions could be thrown by expressions executed by this operator).
select
operator iterates the object by calling AbstractIterator::next(), and the implicit argument $1
in expression is the value returned by AbstractIterator::getValue(); in this case the operator always returns a list (which may be empty if expression returns False for all elements in the iterator object or if the iterator object is empty), and the value of the object in the list returned is the value returned by AbstractIterator::getValue().select
list_expression, expression Arguments Processed by select
Argument | Processing |
list_expression | The list to process or an object inheriting AbstractIterator |
expression | The expression will be evaluated on each element of the list, the implicit argument $1 represents current element of the list (or the iterator object itself when list_expression is an object inheriting AbstractIterator); only if the expression evaluates to True will the element appear in the result list |
This operator does not throw any exceptions (however note that exceptions could be thrown by the expression executed by this operator).
elements
expression Arguments Processed by elements
Argument | Processing |
expression list | Returns the number of elements in the list |
expression hash | Returns the number of keys in the hash |
expression string | Returns the number of characters in the string (which may be different than the number of bytes for multi-byte character encodings such as UTF-8 |
expression binary | Returns the number of bytes in the binary object |
This operator does not throw any exceptions.
keys
hash_expression Arguments Processed by keys
Argument | Processing |
hash_expression | Returns a list of strings giving the keys in hash_expression, which must evaluate to a hash. If not, then no value is returned. |
This operator does not throw any exceptions.
*
expression2 Arguments Processed by * (in order of precedence)
Argument | Processing |
number | Gives the result of multiplying its arguments; ints and floats are converted to numbers if at least one of the arguments is a number |
float | Gives the result of multiplying its arguments; ints are converted to floats if at least one of the arguments is a float |
int | Gives the result of multiplying its arguments |
any other type | Converts argument to a number and performs the multiplication |
This operator does not throw any exceptions.
/
expression2 Arguments Processed by / (in order of precedence)
Argument | Processing |
number | Gives the result of dividing its arguments; ints and floats are converted to numbers if at least one of the arguments is a number |
float | Gives the result of dividing its arguments; ints are converted to floats if at least one of the arguments is a float |
int | Gives the result of dividing its arguments |
any other type | Converts argument to a number and performs the division |
DIVISION-BY-ZERO | division by zero error |
%
expression2 Arguments Processed by %
Argument | Processing |
int | Gives expression1 modula expression2 (ex: 12 % 10 result in 2 ). Arguments are converted to integers if necessary. |
This operator does not throw any exceptions.
+
expression2 Arguments Processed by + (in order of precedence)
Argument | Processing |
list list | Gives the result of concatenating its arguments, i.e. (1, 2) + (3, 4) = (1, 2, 3, 4) |
string | Gives the result of concatenating its arguments |
date | Gives the result of adding date/time values (see Date/Time Arithmetic) |
number | Gives the result of adding its arguments |
float | Gives the result of adding its arguments |
int | Gives the result of adding its arguments |
hash | Gives the result of concatenating/merging its arguments. Any common keys will be overwritten by the values in the second hash (expression2) |
This operator does not throw any exceptions.
-
expression2 Arguments Processed by - (in order of precedence)
Argument | Processing |
date | date subtraction: expression1 - expression2 |
number | arithmetic subtraction: expression1 - expression2 |
float | arithmetic subtraction: expression1 - expression2 |
int | arithmetic subtraction: expression1 - expression2 |
hash - string | hash key deletion: expression1 - expression2 |
hash - list | hash key deletion: expression1 - expression2; all elements of the list are converted to strings (if necessary) and any keys with those names are deleted from the hash. |
This operator does not throw any exceptions.
>>
expression2 Arguments Processed by >>
Argument | Processing |
int | Gives the result of shifting expression1 right by expression2 bits. Arguments are converted to integers if necesssary. |
This operator does not throw any exceptions.
<<
expression2 Arguments Processed by <<
Argument | Processing |
int | Gives the result of shifting expression1 left by expression2 bits. Arguments are converted to integers if necessary. |
This operator does not throw any exceptions.
instanceof
class_identifier Arguments Processed by instanceof
Argument | Processing |
expression | If expression is an instance of the named class, then the operator returns True, otherwise returns False. The operator will return True if the class is a base class, also even if it is privately inherited. |
This operator does not throw any exceptions.
exists
expression Arguments Processed by exists
Argument | Processing |
expression | If expression evaluates to a value, then the operator returns True, otherwise returns False. |
This operator does not throw any exceptions.
("1" < 2)
is True).Arguments Processed by < (in order of precedence)
Argument | Processing |
number | If expression1 is numerically less than expression2, returns True, otherwise returns False |
float | If expression1 is numerically less than expression2, returns True, otherwise returns False |
int | If expression1 is numerically less than expression2, returns True, otherwise returns False |
string | If expression1 comes before expression2 in string sort order, returns True, otherwise returns False |
date | If expression1 is before (or a shorter amount of time than of the arguments are Relative Date/Time Values (Durations)) expression2, returns True, otherwise returns False |
This operator does not throw any exceptions.
("2" > 1)
is True).Arguments Processed by > (in order of precedence)
Argument | Processing |
number | If expression1 is numerically greater than expression2, returns True, otherwise returns False |
float | If expression1 is numerically greater than expression2, returns True, otherwise returns False |
int | If expression1 is numerically greater than expression2, returns True, otherwise returns False |
string | If expression1 comes after expression2 in string sort order, returns True, otherwise returns False |
date | If expression1 is after expression2, returns True, otherwise returns False |
This operator does not throw any exceptions.
("1" == 1)
is True). For absolute equals, where types must also be equal to return true, see the Absolute Equals Operator (===).Arguments Processed by == (in order of precedence)
Argument | Processing |
string | If expression1 is equal to expression2, returns True, otherwise False |
number | If expression1 is equal to expression2, returns True, otherwise False |
float | If expression1 is equal to expression2, returns True, otherwise False |
int | If expression1 is equal to expression2, returns True, otherwise False |
date | If expression1 is equal to expression2, returns True, otherwise False |
list | If each element in the each list where order is relevant satisfies this operator, the operator returns True, otherwise it returns False |
hash | If each hash has the same keys and the value of each equal key in each hash satisfies this operator, the operator returns True, otherwise it returns False |
binary | If expression1's memory contents and size are equal to expression2's, then returns True, otherwise False |
object | If expression1 is a reference to the same object as expression2, then returns True, otherwise False |
NULL | If both expressions are NULL, returns True, otherwise returns False |
NOTHING | If neither expression has a value, returns True, otherwise returns False |
This operator does not throw any exceptions.
("1" != 1)
is False).Arguments Processed by != (in order of precedence)
Argument | Processing |
string | If expression1 is not equal to expression2, returns True, otherwise False |
number | If expression1 is not equal to expression2, returns True, otherwise False |
float | If expression1 is not equal to expression2, returns True, otherwise False |
int | If expression1 is not equal to expression2, returns True, otherwise False |
date | If expression1 is not equal to expression2, returns True, otherwise False |
list | If each element in the each list where order is relevant satisfies this operator, the operator returns True, otherwise it returns False |
hash | If the hashes have different keys or the value of each equal key in each hash satisfies this operator, the operator returns True, otherwise it returns False |
binary | If expression1's memory contents or size are not equal to expression2's, then returns True, otherwise False |
object | If expression1 is not a reference to the same object as expression2, then returns True, otherwise False |
NULL | If either expressions is not NULL, returns True, otherwise returns False |
NOTHING | If one of the expressions has a value, returns True, otherwise returns False |
This operator does not throw any exceptions.
("1" <= 2)
is True).Arguments Processed by <= (in order of precedence)
Argument | Processing |
number | If expression1 is numerically less than or equal to expression2, returns True, otherwise returns False |
float | If expression1 is numerically less than or equal to expression2, returns True, otherwise returns False |
int | If expression1 is numerically less than or equal to expression2, returns True, otherwise returns False |
string | If expression1 comes before in string sort order or is the same as expression2, returns True, otherwise returns False |
date | If expression1 is before or is the same exact date and time as expression2, returns True, otherwise returns False |
This operator does not throw any exceptions.
("2" >= 1)
is True).Arguments Processed by >= (in order of precedence)
Argument | Processing |
number | If expression1 is numerically greater than or equal to expression2, returns True, otherwise returns False |
float | If expression1 is numerically greater than or equal to expression2, returns True, otherwise returns False |
int | If expression1 is numerically greater than or equal to expression2, returns True, otherwise returns False |
string | If expression1 comes after in string sort order or is the same as expression2, returns True, otherwise returns False |
date | If expression1 is after or is the same exact date and time as expression2, returns True, otherwise returns False |
This operator does not throw any exceptions.
Arguments Processed by <=> (in order of precedence)
Argument | Processing |
string | If expression1 comes after in string sort order as expression2, returns 1 , otherwise if they are equal, returns 0 , otherwise if expression1 comes before expression2, returns -1 |
number | If expression1 is numerically greater than expression2, returns 1 , otherwise if they are equal returns 0 , otherwise returns -1 |
float | If expression1 is numerically greater than expression2, returns 1 , otherwise if they are equal returns 0 , otherwise returns -1 |
int | If expression1 is numerically greater than expression2, returns 1 , otherwise if they are equal returns 0 , otherwise returns -1 |
date | If expression1 is after expression2, returns 1 , otherwise if they are equal returns 0 , otherwise returns -1 |
This operator does not throw any exceptions.
Arguments Processed by ===
Argument | Processing |
All | This operator returns True only if the types and values of both sides of the operator are exactly equal, otherwise returns False. No type conversions are done. |
This operator does not throw any exceptions.
Arguments Processed by !==
Argument | Processing |
All | This operator returns True if either the types or the values of the arguments are different, otherwise it retuns False. No type conversions are done. |
This operator does not throw any exceptions.
i
, s
, x
, and m
options after the regular expression.=~ [m]/
regex/[isxm]
Arguments Processed by =~
Argument | Processing |
string | This operator returns True if the regular expression in regex matches the string in expression. |
This operator does not throw any exceptions.
i
, s
, x
, and m
options after the regular expression.!~ [m]/
regex/[isxm]
Arguments Processed by !~
Argument | Processing |
string | This operator returns True if the regular expression in regex does not match the string in expression. |
This operator does not throw any exceptions.
$1
=first subpattern, $2
=second subpattern, etc... See regex_options for the meaning of the i
, s
, x
, and m
options after the regular expression.=~ s/
regex_pattern/
target_string/[isxmg]
Arguments Processed by =~ s///
Argument | Processing |
string | This operator substitutes text in the lvalue string if the regular expression matches. Subpattern backreferences are supported in target_string, $1 =first subpattern, $2 =second subpattern, etc.. |
This operator does not throw any exceptions.
i
, s
, x
, and m
options after the regular expression.=~ x/
regex_with_patterns/[isxm]
Arguments Processed by =~ x//
Argument | Processing |
string | This operator extracts strings from string based on patterns enclosed in parentheses in the regular expression. |
This operator does not throw any exceptions.
=~ tr/
source_chars/
target_chars/
Arguments Processed by =~ tr//
Argument | Processing |
string | This operator substitutes characters in the lvalue string. Note that if there are more characters in source_chars than in target_chars, then the last character in target_chars will be used for any source matches where the source character position is greater than the length of target_chars. |
This operator does not throw any exceptions.
Arguments Processed by &
Argument | Processing |
int | Gives the result of the binary (bitwise) AND operation between expression1 and expression2 (ex: 0xffb2 & 0xa1 = 0xa1 ); operands are converted to integers if necessary. |
This operator does not throw any exceptions.
Arguments Processed by |
Argument | Processing | |
int | Gives the result of the binary (bitwise) OR operation between expression1 and expression2 (ex: 0xb001 | 0xfea = 0xbfeb ); operands are converted to integers if necessary |
This operator does not throw any exceptions.
Arguments Processed by ^
Argument | Processing |
int | Gives the result of the binary (bitwise) EXCLUSIVE OR operation between expression1 and expression2 (ex: 0xaef1 & 0xfb32 = 0x55c3 ); operands are converted to integers if necessary |
This operator does not throw any exceptions.
Arguments Processed by &&
Argument | Processing |
bool | Returns True if both expressions are True, False if otherwise. Logical short-circuiting is implemented; if expression1 is False, then expression2 is not evaluated, and the operator returns False. |
This operator does not throw any exceptions.
Arguments Processed by ||
Argument | Processing |
bool | Returns True if either or both expressions evaluate to True, False if otherwise. Logical short-circuiting is implemented; if expression1 is True, then expression2 is not evaluated, and the operator returns True. |
This operator does not throw any exceptions.
Arguments Processed by ? :
Argument | Processing |
All | If expression is evaluated to be True, then the if_true_expression is evaluated and returned. Otherwise the if_false_expression is evaluated and returned. |
This operator does not throw any exceptions.
Arguments Processed by ,
Argument | Processing |
All | The comma operator builds lists of arguments |
This operator does not throw any exceptions.
unshift
lvalue, expression Arguments Processed by unshift
Argument | Processing |
All | Inserts the value of expression as the first element in the list given by lvalue. All other elements in the list are moved forward. |
push
lvalue, expression Arguments Processed by push
Argument | Processing |
All | Appends the value of the expression as the last element in the list given by lvalue. If expression evaluates to a list, this list will be appended as the last element of lvalue. To concatenate lists, use the plus operator. |
UTF-8
splice
lvalue, offset_expression, [length_expression, [substitution_expression]]Arguments Processed by splice
Argument | Processing |
lvalue (list, string, or binary) | If the lvalue is a list, list elements are processed, if it is a string, characters in the string are processed, and for binary data, bytes are processed. For any other data type, no action is taken. |
offset_expression | The start element/character/byte position for removing elements/characters/bytes from the list, string, or binary data; if this value is negative, it gives the element offset from the end of the data |
length_expression | The number of elements/characters/bytes to remove. If this expression is not present, then all elements/characters/bytes from the offset to the end of the list/string/binary data are removed. If this expression is present and evaluates to 0, no characters/elements/byte are removed; if this value is negative, then it gives an offset from the end of the data (ie -2 means remove all elements/characters/bytes up to but not including the last two) |
substitution_expression | For list splice, an optional element or list to substitute for the removed elements (to insert a list in a single element's position, make sure that the list to be inserted is the first and only element of another list used as the argument in this position; in other words, pass a list within a single-element list). For string splice, an optional string to substitute for the removed characters. For binary splice, string or binary data to substitute for any removed bytes. |
UTF-8
extract
lvalue, offset_expression, [length_expression, [substitution_expression]]Arguments Processed by extract
Argument | Processing |
lvalue (list, string, or binary) | If the lvalue is a list, list elements are processed, if it is a string, characters in the string are processed, and for binary data, bytes are processed. For any other data type, no action is taken. |
offset_expression | The start element/character/byte position for removing elements/characters/bytes from the list, string, or binary data; if this value is negative, it gives the element offset from the end of the data |
length_expression | The number of elements/characters/bytes to remove. If this expression is not present, then all elements/characters/bytes from the offset to the end of the list/string/binary data are removed. If this expression is present and evaluates to 0, no characters/elements/byte are removed; if this value is negative, then it gives an offset from the end of the data (ie -2 means remove all elements/characters/bytes up to but not including the last two) |
substitution_expression | For list extract, an optional element or list to substitute for the removed elements (to insert a list in a single element's position, make sure that the list to be inserted is the first and only element of another list used as the argument in this position; in other words, pass a list within a single-element list). For string splice, an optional string to substitute for the removed characters. For binary splice, string or binary data to substitute for any removed bytes. |
=
expression Arguments Processed by =
Argument | Processing |
All | Assigns the value of expression to lvalue |
+=
expression Arguments Processed by +=
Argument | Processing |
lvalue (list) | the expression will be evaluated and concatenated to the lvalue. If expression is a list, the lists will be concatenated, to ensure adding a single element to a list, use the push operator |
lvalue (hash or (object) | the expression will be evaluated, and, if it is a hash or object, then it's members will be added to the lvalue, any duplicate elements in the lvalue will be overridden by elements in the expression. |
lvalue (string) | the expression will be evaluated and converted to a string if necessary and concatenated to the lvalue. |
lvalue (number) | the expression will be evaluated and converted to a number if necessary and added to the lvalue. |
lvalue (float) | the expression will be evaluated and converted to a float if necessary and added to the lvalue. |
lvalue (binary) | the expression will be evaluated and converted to a binary if necessary and added to the lvalue. |
lvalue (date) | the expression will be evaluated and converted to a date if necessary and added to the lvalue. |
lvalue (NOTHING) | the lvalue will be assigned to the value of expression. |
lvalue (all other types) | the lvalue's type will be converted to an integer, and the expression will be evaluated and converted to an integer if necessary, and then the result will be added to the lvalue. |
-=
expression Arguments Processed by -=
Argument | Processing |
lvalue (number) | the expression will be evaluated and converted to a number if necessary and subtracted from the lvalue |
lvalue (float) | the expression will be evaluated and converted to a float if necessary and subtracted from the lvalue |
lvalue (date) | the expression will be evaluated and converted to a date if necessary and subtracted from the lvalue |
lvalue (hash or (object), expression (string) | the hash key represented by expression will be removed from the lvalue |
lvalue (hash or (object), expression (list) | each element in the list will be converted to a string (if necessary) and the key represented by each string will be removed from the hash or object |
lvalue (NOTHING), expression (any type) | the expression will be assigned to lvalue |
lvalue (all other types) | the lvalue's type will be converted to an integer (if necessary), and the expression will be evaluated and converted to an integer (if necessary), and then the result will be subtracted from the lvalue |
&=
expression Arguments Processed by &=
Argument | Processing |
All | the lvalue's type will be converted to an integer if necessary, and the expression will be evaluated and converted to an integer as well if necessary, and then the result will be binary and'ed to the lvalue |
|=
expression Arguments Processed by |=
Argument | Processing |
All | the lvalue's type will be converted to an integer if necessary, and the expression will be evaluated and converted to an integer as well if necessary, and then the result will be binary or'ed to the lvalue |
%=
expression Arguments Processed by %=
Argument | Processing |
All | the lvalue's type will be converted to an integer if necessary, and the expression will be evaluated and converted to an integer as well if necessary, and then the result will be used to divide the lvalue's value and the remainder will be saved to the lvalue |
*=
expression Arguments Processed by *=
Argument | Processing |
All | The type precedence from highest to lowest is number, float float, and int, other types are converted to int. The expression will be evaluated and multiplied by the lvalue, and the result will be saved to the lvalue. |
/=
expression Arguments Processed by /=
Argument | Processing |
All | The type precedence from highest to lowest is number, float float, and int, other types are converted to int; The expression will be evaluated and multiplied by the lvalue, and the result will be saved to the lvalue. The expression will be evaluated and used to divide the lvalue, and the result will be saved to the lvalue. |
DIVISION-BY-ZERO | If the divisor expression evaluates to zero, this exception is thrown |
^=
expression Arguments Processed by ^=
Argument | Processing |
All | Values are converted to integers if necessary. The expression will be evaluated and exclusive-or'ed with the lvalue, and the result will be saved to the lvalue |
<<=
expression Arguments Processed by <<=
Argument | Processing |
All | Values are converted to integers if necessary. The expression will be evaluated and this value will determine how many bits the lvalue will be shifted left. The result will be saved to the lvalue. |
>>=
expression Arguments Processed by >>=
Argument | Processing |
All | Values are converted to integers if necessary. The expression will be evaluated and this value will determine how many bits the lvalue will be shifted right. The result will be saved to the lvalue. |