I am sure that if you really want you to try to apply some scheme in which the variational function accepts only a certain type of parameter (for example, a list of ints) - and then you fill in some global variable indicating how many ints you have passed.
Your two examples are not variational functions. These are functions with two arguments, but they also highlight a similar problem. How to find out the size of a C array without additional information? You can either pass the size of the array, or describe a circuit with a number of sentinel values, unmapping the end of the array (ie "\ 0" for string C).
As in the case of the variational register, and in the case of the array, you have the same problem, how can you find out how much data you have legal access? If you do not know this in the case of an array, you will go beyond. If you do not know this in the variational case, you will call va_arg too many times or with the wrong type.
To include the question, how would you implement a function with a variable number of arguments without passing additional information?
source share