docs.roxen.comView this page in a printer friendly mode
DocsPike7.0TutorialExpressions
Copyright © 2012, Roxen Internet Software
Suggestions, comments & compliments
manuals@roxen.com
 DEMO  DOCS  PIKE
 COMMUNITY  DOWNLOAD
www.roxen.com

   

Some Terminology
Arithmetical Operations
Operations on Complex Types
Comparison
Logical Expressions
Bitwise Operations
Operations on Sets
Indexing
Assignment
Type Conversions
The Comma Operator
Call and Splice
Operator Precedence and Associativity

Call and Splice

In this section we explain two operators that are used in connection with calls to methods: the method-call operator and the splice operator.

A method call, which we have seen many examples of, is actually a use of the method-call operator. It is written with a pair of parentheses according to this template:

method-expression ( argument-list )

First the method-expression is calculated, to find out which method to call. The method-expression is often a single identifier, such as write, but can be more complicated. Then all the expressions in the comma-separated argument-list are calculated. Finally, the method is executed, with the argument values as parameters.

Some notes about the method-call operator:

  • If the value of the method-expression is an array, Pike assumes that each element in the array is a method that can be called. Pike will call each method in that array, with the given arguments, and the result of all this is an array with the return values from the calls.

  • If the value of the method-expression is a program (that is, a class), Pike will create (or clone) a new object from that class, and then call the method create in that object, with the given arguments.

The splice operator, written with a commercial-at sign (@), lets us use an array as an argument list. For example,

array a = ({ 17, -0.3, "foo" });
koogle(@a);

is equivalent to

koogle(17, -0.3, "foo");