How to declare an alias to a function literal type
ParticlePeter via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Jan 12 08:55:48 PST 2016
On Tuesday, 12 January 2016 at 16:22:48 UTC, ParticlePeter wrote:
> Actually, I do use only one param, and not int as well, hence I
> would like the parameter list to be part of the alias.
> Your example works though.
This was confusing, lets start fresh:
I have a function "otherFunc" which takes a function with lots of
parameters as argument:
void otherFunc( void function( ref int p1, float p2, ubyte p3,
... ) mf );
Side-note, I use the keyword function to signal that it is a
function and not a delegate, thought it is a delegate when not
specified.
When I pass a parameter to otherFunc I use this syntax for an
anonymous function parameter:
otherFunc( void function( ref int p1, float p2, ubyte p3 ) {
myCode; } );
I would like to alias the function signature above:
alias MF = void function( ref int p1, float p2, ubyte p3 );
I can rewrite the definition of otherFunc like this:
void otherFunc( MF mf );
But I cannot pass an anonymous function to otherFunc like this:
otherFunc( MF { myCode; } );
Thats what I want. Any working example?
Ali, I do not pass an existing named function as a pointer. I am
also not sure about the lambdas, as I do not return anything, I
just want to process data, would that work?
More information about the Digitalmars-d-learn
mailing list