````D
struct pair
{
float x,y;
}
myFunction(float taco, float x, float y, float burrito)
{
// stuff
}
myfunction(_taco, _x, _y, _burrito); // call function
// But can we do this?
pair p;
myfunction(_taco, p; _burrito); // p becomes (x,y) and satisfies
the two floats in the signature
````
I don't know if I need this but I'm curious if it's a template
possibility. Though under-the-hood it could violate some
necessary assumption about function signature matching.
I'm curious if you can pass a struct of values (a 'tuple'?) with
the right subfields, as if those fields occupied a function
signature. (As I write this and try to explain it, it probably
sounds impossible.)
I have an existing API that uses X/Y coordinates, but I like
using packed/named tuples (right term?) for related arguments.
pos(x,y) vs velocity(x,y) for example make it super easy to tell
which x belongs to which construct. Worst case I could just write
wrapper functions for like 60+ functions. But it's still an
interesting "can D do this" idea that popped into my head
tonight. I'm always curious about what's possible.
- Note that it doesn't necessarily have the struct fields match
the called function argument names. I'm talking about calling
with a struct with two floats (of any name), fulfilling two float
requirement of a function signature. Is there a way for a
tuple/array/some-sort-of-combined object to fulfill two separate
function arguments?
Of course we could always just do:
````D
pair p;
myFunction(taco, p.x, p.y, burrito);
````