Trass3r <u...@known.com> wrote:

2. What is the reason for Phobos defining param funcs as template
params?

Correct me if I'm wrong but there's no way to pass an arbitrary
function to a function in a type-safe way. If you use pointers and
casts you can't check if the passed function meets certain
requirements (parameters, return type, attributes, etc.)

It is perfectly possible to typesafely pass a function or delegate to
a function:

void foo( F )( F fn ) {
    fn();
}

You can then add other things to pass parameters:

void foo( F )( F fn, ParameterTypeTuple!F args ) {
    fn( arg );
}

Of course, given a non-template function, it is impossible to safely
pass a function to it.

--
Simen

Reply via email to