|
|
|
class AClass { public String adder(String s) { return s; } } // case 1 static call defun StaticStringAdder static String (String s); // -> interface StaticStringAdder { public String operator()(String s); } // <- StaticCallable staticcallable; // -> just an Interface reference staticcallable = acls.method; // -> class AClass_method_caller implements StaticStringAdder { AClass target; AClass_method_caller(AClass t) : target(t) {} public String operator(String s) { return target.adder(s); } } staticcallable = new AClass_method_caller(acls); // <- |
Defintion|
defun TypeName FunctionSignature |
Sample
Initialize with Functions|
defun FooCallable String (String s, int i); String fooFunction(String s, int i) { return s.substr(i); } FooCallable callable; callable = fooFunction; callable("Hello", 1); |
Initialize with object instance Methods|
defun FooCallable String (String s, int i); class AClass { public AClass() {} public String bar(String s, int i) { return s.substr(i); } } FooCallable callable; AClass acls = new AClass(); callable = acls.bar; callable("Hello", 1); |
Initialize with object|
defun FooCallable staticString (String s, int i); class AClass { public AClass() {} public String operator()(String s, int i) { return s.substr(i); } } FooCallable callable; AClass acls = new AClass(); callable = acls; callable("Hello", 1); |
Initialize with class|
defun String FooCallable(String s, int i); class AClass { public static String operator()(String s, int i) { return s.substr(i); } } FooCallable callable; callable = AClass; callable("Hello", 1); |
Working with operators|
defun StringShifter String operator<<(String str); String operator<<(String s) { return str.length() << 1; } StringShifter shifter = |
Implementation|
using acdk.lang; String foo(String s, int i) { return s.substr(i); } foo("Hallo", 1); // will be translated into class foo { public static String operator()(String s, int i) { return s.substr(i); } } foo.operator()("Hallo", 1); |