foreach, opApply, and inline
BCS
ao at pathlink.com
Mon Oct 8 07:41:11 PDT 2007
Reply to Tor,
> BCS <ao at pathlink.com> wrote:
>
>> I have often though that the inlining should work in the more general
>> case where small function get called with a known delegate.
>>
> I don't think it should in general; if the "small function" calls the
> delegate multiple times, this can result in extremely bloated code.
>
Well of course any optimization needs to be implemented with some sanity
checks.
What I want to be dealt with is the idiom where a call to a small function
takes a delegate literal. Say something like this
void Attr(char[] s)(void delegate() dg
{
writef("<"~s~"> ");
scope(exit) writef("<"~s~"> ");
dg();
}
alias Attr!("b") Bold
alias Attr!("http") Doc
alias Attr!("body") Body
alias Attr!("head") Head
Doc({
Head({
...
});
Body({
writef("Hello ");
Bold({
writef("world");
});
});
});
More information about the Digitalmars-d
mailing list