C++ vs Lisp
Nick Sabalausky
a at a.a
Sun May 18 00:52:00 PDT 2008
"janderson" <askme at me.com> wrote in message
news:g0o03o$k01$1 at digitalmars.com...
> Nick Sabalausky wrote:
>> "Dee Girl" <deegirl at noreply.com> wrote in message
>> news:g0noqa$2rpf$1 at digitalmars.com...
>>> There was long discussion here. Maybe you did not read.
>>>
>>
>> Didn't see it, must have been on a different thread.
>>
>>> void slowbad(delegate void() f)
>>> {
>>> f();
>>> }
>>>
>>> void fastgood(alias f)()
>>> {
>>> f();
>>> }
>>>
>>> void main()
>>> {
>>> void f() { }
>>> slowbad(&f);
>>> fastgood!(f);
>>> }
>>>
>>> Syntax is different but power is very different. std.algorithm uses
>>> alias always. Everybody else uses slowbad ^_^ Dee Girl
>>
>> Isn't that akin to forcing a function to be inlined? It sounds to me
>> like, just as with normal function inlining, there are cases where that
>> could backfire because of things like increased cache misses or increased
>> register consumption (or are those outdated problems with inlining?).
>
> Only if the compiler decided to inline the contents of f function. Even
> then if the compiler can inline f's contents, its probably going to beable
> to reduce the size of the program size somewhat. Normally the compiler is
> going to get it right with inlining. The above template will boil down
> to:
>
> void main()
> {
> void f() { }
> slowbad(&f); //May or maynot be inlined
> f();
> }
>
> As you can see f() is one function call less then slowbad and doesn't have
> to do any of the other stuff slowbad would.
>
But fastgood() is always inlined, right?
More information about the Digitalmars-d
mailing list