May 23, 2010
Hello,

I've dabbled in D here and there, and love it.  From what I can see, though, there's not exactly an "inline" keyword for function inlining.  I know that the D compiler can do inlining by adding "-inline", but that doesn't really allow one to mark specific functions for inlining.  Is there any way to achieve manual inlining of a function?  I'm starting to think that possibly mixins can do this, but I'm not sure.  If I understand the documentation, I think it would work like this:

template mixin Foo(alias x, alias y)
{
   int add() {return x + y}
   int sub() {return x - y}
}

void main()
{
   int sum;
   int a = 5;
   int b = 2;

   mixin Foo!(a, b);
   sum = add();
}


If I understand the documentation, the compiler will inline whichever function I call from the template mixin Foo, and leave out whichever functions I don't call--correct?  Do I need to add on -inline for it to work?
May 23, 2010
Hello RedZone,

> Hello,
> 
> I've dabbled in D here and there, and love it.  From what I can see,
> though, there's not exactly an "inline" keyword for function inlining.
> I know that the D compiler can do inlining by adding "-inline", but
> that doesn't really allow one to mark specific functions for inlining.
> Is there any way to achieve manual inlining of a function?

No. D by choice decided to omit that. The thought is that even in language that have it, inline is just a suggestion. D in effect just assumes the suggestion for everything and lets the compiler sort it out.

-- 
... <IXOYE><