I seem to recall that in C, one can define multiple function declarations for the same function. Is it possible to do the same at Pike level?
Example, I have a function declared as void foo(mixed ... bar); Now I want to check, and enforce two different declarations:
void foo(string s, mixed ... bar); void foo(function f, string s, mixed ... bar);
Can I, at Pike level, declare somehow that the above two prototypes are the only two valid prototypes for this function? So that Pike will give me a syntax error if I try to do foo(23); ?
This feature was added to pike 8.0 recently, it is using the 'variants' keyword. There is several examples amoung the modules which use that.
Arne
On 09/23/16 16:30, Stephen R. van den Berg wrote:
I seem to recall that in C, one can define multiple function declarations for the same function. Is it possible to do the same at Pike level?
Example, I have a function declared as void foo(mixed ... bar); Now I want to check, and enforce two different declarations:
void foo(string s, mixed ... bar); void foo(function f, string s, mixed ... bar);
Can I, at Pike level, declare somehow that the above two prototypes are the only two valid prototypes for this function? So that Pike will give me a syntax error if I try to do foo(23); ?
pike-devel@lists.lysator.liu.se