d optimization: delegates vs. mixin
zoli
zoli at freemail.hu
Wed Oct 21 09:45:23 PDT 2009
Can the compiler optimize the delegates (foo) to form an inline code, or the mixin version is prefered?
module a;
import std.stdio;
void foo2( string s )()
{
for( int i = 0 ; i < 10; i++ )
{
mixin( s );
}
}
void foo( void delegate(int) pDg )
{
for( int i = 0 ; i < 10; i++ )
{
pDg( i );
}
}
void main()
{
foo( (int a){ writeln( a ); } );
foo2!("writeln( i );")();
}
Thank you 1
More information about the Digitalmars-d
mailing list