Open Blub opened 11 years ago
About typechecking:
void takestrings(string...) { /* stuff */ }
void myfunc(...) {
/* code */
takestrings(...(n)); // This should error unless -fpermissive
takestrings(...(n, string...)); // tells the compiler "myfunc wasn't restricted but I know what I'm doing here"
}
Recursion issue:
void foo(...) {
foo(1, ...(0));
}
This essentially requires an infinite amount of parameters, so we'll need a hard upper bound of possible varargs which is bigger than the current limit.
Proposal: --max-variadic-growth=16
would mean you get at most 16 more variadic parameters then you ever explicitly pass to a function. iow the above foo
could recurse 16 times since it adds 1 parameter per recursion.
Max variadic depth is a good idea.
I tried the following code and there doesn't seem to be a recursion issue in the compiler, just at runtime. Or is a max-depth already implemented? Looks fine.
Pushing this back to a later milestone since 0.3.0 was released about 5 minutes ago.
How "unexpected" - as mentioned back in #17 we should actually have a way to pass on multiple varargs. The previously proposed syntax was.
Note: this would be limited to be the last parameter in a function call.