Treat a normal function as variadic?
Robin Allen
r.a3 at ntlworld.com
Wed May 30 06:05:42 PDT 2007
void f0() {}
void f1(...) {}
void main()
{
auto pf0 = &f0;
auto pf1 = &f1;
writefln(typeid(typeof(pf0)));
writefln(typeid(typeof(pf1)));
}
The above program shows pf0 and pf1 to have the same type, 'void()*'.
(Which, incidentally, isn't a type. Shouldn't it be 'void(*)()'?)
The thing is, I can call pf1(64), but not pf0(64) (wrong number of
arguments), even though pf0 and pf1 should behave identically, having
the same type.
Basically, I need a way to treat a non-variadic function as if it were
variadic. I'm asking because I'm writing a scripting language, and I
want to make normal D functions callable from the script, where the
number of arguments given isn't known at compile time.
More information about the Digitalmars-d-learn
mailing list