Right now there are two forms of varargs:
def varargs(...)
def varargs(a: int...)
The first one just exists for C interop and the second one creates an array. It is possible to accept any type with the second variant by using a void reference but the issue with that is that it's purely a runtime thing and you need to inspect the runtime type of your arguments.
This could be the third variant which basically passes a tuple of the types which can be examined at compile time.
Doing so could be done like this:
def varargs(a: type...) {
#if a.length == 1 {
const first = a[0]
type F = type_of a[0]
...
}
}
Right now there are two forms of varargs:
The first one just exists for C interop and the second one creates an array. It is possible to accept any type with the second variant by using a void reference but the issue with that is that it's purely a runtime thing and you need to inspect the runtime type of your arguments.
This could be the third variant which basically passes a tuple of the types which can be examined at compile time.
Doing so could be done like this: