Using the method I posted with an array of only 10 elements will allow calls like:
Code: Select all
cSum2(cSum2(cSum2(cSum2(cSum2(cSum2(cSum2(cSum2(A,B),B),B),B)B),B),B),cSum2(A,cSum2(A,B)))
Code: Select all
;with variable
C.csi
CopyStructure(cSum2(A,B), C, csi)
;or with pointers
*D.csi
CopyStructure(cSum2(csum2(B,A), B), *D, csi)
I've used the approach that you demonstrated first where you passed the pointer in. This requires some acrobatic work to perform nested calls by using lots of single calls. The method that allocates a new structure each time requires you to free it when you're done with it. As you know that method doesn't work with nested calls without memory leaks.
Since your goal is to make nested calls and to keep the parameter count down I think the static array method would be a good choice. You only need to decide on how many indices to set aside to handle the depth of nesting that you expect. As you can see from my example above that can probably be kept under 10.
It would be great if this process was automated and made native. In the mean time it is not very difficult to implement it this way. If thread safety is needed it does get messier.