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:28:25 PST 2016


On Tuesday, 12 January 2016 at 16:00:37 UTC, Daniel Kozak wrote:
> V Tue, 12 Jan 2016 15:41:02 +0000
> ParticlePeter via Digitalmars-d-learn
> <digitalmars-d-learn at puremagic.com> napsáno:
>
>> I have a function type and variable and assign a function to 
>> it:
>> 
>> void function( int i ) myFunc;
>> myFunc = void function( int i ) { myCode; }
>> 
>> How would I declare an alias for void function( int i ) such 
>> that the case above would work like this:
>> 
>> // alias MF = void function( int i );  // not working
>> // alias void function( int i ) MF;  // not working
>> 
>> MF myFunc;
>> myFunc = MF { myCode };
>> 
>> Please, if possible, also show me where I should have found 
>> the answer (D Reference, Alis book, etc. )
>
> alias void MF(int i);

That does not work:
alias void MF(int i);
MF mf;     // Error: variable mf cannot be declared to be a 
function




More information about the Digitalmars-d-learn mailing list