-
Notifications
You must be signed in to change notification settings - Fork 1
/
ici-core8.ici
27 lines (26 loc) · 835 Bytes
/
ici-core8.ici
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// The closure() function returns an object that "binds" some number of
// arguments to a function so that calling the returned object calls
// that function with the "bound" arguments.
//
// Any extra arguments passed in the call are passed as additional
// arguments to the bound function. I.e. partial closures may be
// _filled_ in with the remaining, positional, arguments.
//
extern closure(f) {
var binding = [class
new(f) {
var vargs = @[array];
this = this:^new();
this.f := f;
this.args := vargs;
return this;
}
invocation() {
var vargs = @[array];
return call(this.f, this.args + vargs);
}
];
var vargs = @[array];
bound := call(binding:new, f, vargs);
return bound:invocation;
}