[cap-talk] Last Call for ref_send API 1.0
Sandro Magi
smagi at higherlogics.com
Thu Apr 5 12:28:42 CDT 2007
In the interest of brevity, the gist is:
I'm ok with the FnX approach, and I would suggest X = [1 ... 4] at most.
You can still pass in arrays if you need more arguments, and you can
also group the like types together so no casting is needed.
Dean Tribble wrote:
>> final int b=1;
>> return new Closure<int,int>() {
>> int post(int arg) { return b + arg; } };
>
> The difference is 'that "return delegate(int a, int c) {return a+b-c;}"
> can't be expressed by Closure:)
Right, the closest you get with the current Closure design is:
final int b=1;
return new Closure<int[],int>() {
int post(int[] arg) { return b + arg[0] - arg[1]; } };
It's even less convenient if the args are of different type as you must
then cast before use. The other option is a series of tuple types, but
those don't gain you much over just enumerating the FnX as you suggest
below, except you can then compose tuples to form larger structures if
necessary (you can compose functions to the same thing, but this seems
harder). Probably too complicated for this.
> [...]
> Hence my suggestions of Fn1, Fn2, etc.
Right, a naming convention over a calling convention, which I generally
agree with. Problem is, at some point you need to have an Nary function
FnN, in which case you're passing an array anyway. Rare case I agree,
but the user will probably run into it eventually.
Sandro
More information about the cap-talk
mailing list