What's the best (least overhead and most portable and safe) way wrapping a
function into a variadic-parameter function?
For instance:
long foo(int i, char c)
{
/// ...
}
long bar(...)
{
return foo(/* ??? */);
}
This is necessary for losing the parameter types, but still having the
function callable with its expected parameters. I suspect this could be
done using inline assembler and knowledge of the D ABI to achieve near-zero
overhead.
The wrapper can include dynamic type checking using the automatically
passed _arguments array to ensure type safety.
This is useful for dynamic dispatching.
--
Bye,
Gor Gyolchanyan.

What's the best (least overhead and most portable and safe) way wrapping
a function into a variadic-parameter function?
For instance:
long foo(int i, char c)
{
/// ...
}
long bar(...)
{
return foo(/* ??? */);
}
This is necessary for losing the parameter types, but still having the
function callable with its expected parameters. I suspect this could be
done using inline assembler and knowledge of the D ABI to achieve
near-zero overhead.
The wrapper can include dynamic type checking using the automatically
passed _arguments array to ensure type safety.
This is useful for dynamic dispatching.

It might not be want you need but a variadic template is the easiest
solution:
long bar (Args ...) (Args args)
{
return foo(args);
}
--
/Jacob Carlborg

A function with variadic template parameters is just a function which takes
a set of compile-time known parameters.
My goal is to have a non-template function taking variadic parameters.
long bar(...)
{
return foo(...);
}
This is necessary to be able to pass variables to functions without knowing
the type of the functions.
On Wed, Dec 5, 2012 at 7:33 PM, Jacob Carlborg <doob me.com> wrote:

On 2012-12-05 11:01, Gor Gyolchanyan wrote:

What's the best (least overhead and most portable and safe) way wrapping
a function into a variadic-parameter function?
For instance:
long foo(int i, char c)
{
/// ...
}
long bar(...)
{
return foo(/* ??? */);
}
This is necessary for losing the parameter types, but still having the
function callable with its expected parameters. I suspect this could be
done using inline assembler and knowledge of the D ABI to achieve
near-zero overhead.
The wrapper can include dynamic type checking using the automatically
passed _arguments array to ensure type safety.
This is useful for dynamic dispatching.

It might not be want you need but a variadic template is the easiest
solution:
long bar (Args ...) (Args args)
{
return foo(args);
}
--
/Jacob Carlborg

A function with variadic template parameters is just a function which
takes a set of compile-time known parameters.
My goal is to have a non-template function taking variadic parameters.
long bar(...)
{
return foo(...);
}
This is necessary to be able to pass variables to functions without
knowing the type of the functions.
--
Bye,
Gor Gyolchanyan.

A function with variadic template parameters is just a function which
takes a set of compile-time known parameters.
My goal is to have a non-template function taking variadic parameters.
long bar(...)
{
return foo(...);
}
This is necessary to be able to pass variables to functions without
knowing the type of the functions.
--
Bye,
Gor Gyolchanyan.

A function with variadic template parameters is just a function which takes
a set of compile-time known parameters.
My goal is to have a non-template function taking variadic parameters.
long bar(...)
{
return foo(...);
}
This is necessary to be able to pass variables to functions without knowing
the type of the functions.

Then read the section on variadic functions and pick which type works best for
you: http://dlang.org/function.html
- Jonathan M Davis
P.S. Please stop top posting. It's generally considered rude in lists like
this.

a set of compile-time known parameters.
My goal is to have a non-template function taking variadic parameters.
long bar(...)
{
return foo(...);
}
This is necessary to be able to pass variables to functions without

knowing

the type of the functions.

Then read the section on variadic functions and pick which type works best
for
you: http://dlang.org/function.html
- Jonathan M Davis
P.S. Please stop top posting. It's generally considered rude in lists like
this.

Sorry, force of habit. Gmail puts me at the top and hides the message by
default,
I read about the d-style variadic functions and I also read the ABI.
There are some vast differences in the ABI (the parameters are pushed in
reverse order, the caller must clean the stack...).
I thought that you guys have a better understanding of what's going on, so
you might help me with this.
If done carefully it could be a very valuable addition to std.functional.
--
Bye,
Gor Gyolchanyan.

I read about the d-style variadic functions and I also read the ABI.
There are some vast differences in the ABI (the parameters are pushed in
reverse order, the caller must clean the stack...).
I thought that you guys have a better understanding of what's going on, so
you might help me with this.
If done carefully it could be a very valuable addition to std.functional.

I think that at this point, almost everyone just uses variadic templates when
they want a variadic function. Upon occasion, a typesafe variadic function
makes sense, but C style variadics basically never make sense unless you're
interacting with C, and in general, variadic templates are vastly superior to
D variadics, so it's the variadic templates get used. And as most of just use
the variadic templates, in the case of many of us, our knowledge of D style
variadics is low.
- Jonathan M Davis

I know, that variadic templates are safer, but this use case requires that
the parameter types and quantities should be statically unknown. It's all
part of dynamic dispatch that I'm implementing.
For all we know they might interact with C. As far as I read on
dlang.orgit will require tons of ASM to adapt variadic ABI to
non-variadic ABI.
On Thu, Dec 6, 2012 at 1:14 PM, Jonathan M Davis <jmdavisProg gmx.com>wrote:

On Thursday, December 06, 2012 11:40:24 Gor Gyolchanyan wrote:

I read about the d-style variadic functions and I also read the ABI.
There are some vast differences in the ABI (the parameters are pushed in
reverse order, the caller must clean the stack...).
I thought that you guys have a better understanding of what's going on,

so

you might help me with this.
If done carefully it could be a very valuable addition to std.functional.

I think that at this point, almost everyone just uses variadic templates
when
they want a variadic function. Upon occasion, a typesafe variadic function
makes sense, but C style variadics basically never make sense unless you're
interacting with C, and in general, variadic templates are vastly superior
to
D variadics, so it's the variadic templates get used. And as most of just
use
the variadic templates, in the case of many of us, our knowledge of D style
variadics is low.
- Jonathan M Davis