All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ceylon.language.Callable.ceylon Maven / Gradle / Ivy

There is a newer version: 1.3.3
Show newest version
"A reference to a function. The type arguments encode the 
 [[return type|Return]] of the function along with its 
 [[parameter types|Arguments]]. The parameter types are 
 represented by a tuple type. Functions declared `void` are 
 considered to have the return type `Anything`.
 
 For example, the type of the anonymous function
 `(Float x, Integer y) => x^y+1` is:
 
     Callable
 
 which we usually abbreviate to `Float(Float,Integer)`.
 
 Likewise, the type of the function reference `plus` 
 to the function [[plus]] is:
 
     Callable
 
 which we abbreviate as `Float(Float,Float)`.
 
 A variadic function is represented using an unterminated 
 tuple type. For example, the type of the function reference
 `concatenate` to the function [[concatenate]] is:
 
     Callable
 
 which we usually abbreviate `Object({Object*}*)`.
 
 A function with defaulted parameters is represented using
 a union type. For example, the type of the method reference
 `process.writeLine` to the method [[process.writeLine]] is:
 
     Callable
 
 which we usually abbreviate `Anything(String=)`.
 
 Finally, any type of form `Callable` may be 
 abbreviated to `X(*Y)`.
 
 Any instance of `Callable` may be _invoked_ by supplying a 
 positional argument list:
 
     Float(Float,Float) add = plus;
     value four = add(2.0, 2.0);
 
 or by supplying a tuple containing the arguments:
 
     Float(Float,Float) add = plus;
     [Float,Float] twoAndTwo = [2.0, 2.0];
     value four = add(*twoAndTwo);
 
 The type of the tuple must be assignable to the type 
 argument of `Arguments`.
 
 There is no reasonable and computationally decidable 
 definition of [[value equality|Object.equals]] for a 
 function reference. Therefore, the `equals()` method of an
 instance of `Callable` always returns `false`, and `x==y`
 always evaluates to `false` for any two function references
 `x` and `y`.
 
 This interface may not be implemented by user-written code."
see (`class Tuple`)
tagged("Functions")
shared native interface Callable 
        given Arguments satisfies Anything[] {}