Safer casts

Yigal Chripun yigal100 at gmail.com
Tue May 13 01:57:12 PDT 2008


Dee Girl wrote:
 > It is important because of this. Direct call is trivially inlined.
> Indirect call is maybe 1000 times harder to inline and sometimes
> impossible. By direct call I mean you know the address of the
> function at compilation. By indirect call I mean you have a pointer
> with the address of the function.

again, I'll leave this to Walter to figure out. the decision to inline
is and should be the compiler's.

> 
>> I'm saying here that both options (the template instance and the
>> regular function) do the same regarding inlining the delegate.
> 
> This sentence is incorrect. The template instance works very
> different from the regular function.

you say that sort!(delegate) inlines the call to delegate?
in that case:
dg = dg1;
sort!(dg)(..);
dg = dg2;
sort!(dg)(..);
whould the above produce two different instances?
with classes:
class A { bool method(); }
auto a = new A;
auto b = new B;
dg = &a.method;
sort!(dg)(..);
dg = &b.method;
sort!(dg)(..);
will this produce two instances?

I understood till now that the sort!(delegate)(..) /may/ inline the
delegate but it's not a must.
on the other hand:
sort(delegate,..) currently doesn't inline but /may/ do so in the
future. in the end, both will /maybe/ provide inline capability.
if this is true I don't see any difference.





More information about the Digitalmars-d mailing list