inlining...

Ola Fosheim Grøstad" <ola.fosheim.grostad+dlang at gmail.com> Ola Fosheim Grøstad" <ola.fosheim.grostad+dlang at gmail.com>
Tue Mar 18 23:18:16 PDT 2014


On Wednesday, 19 March 2014 at 01:28:48 UTC, Manu wrote:
> In the case you do want to inline the whole tree, you can just 
> cascade the
> mixin through the stack. In the case you suggest which flattens 
> the tree by
> default, we've lost control; how to tell it only to do it for 
> one level
> without hacks? And I believe this is the common case.

You could provide it with a recursion level parameter or 
parameters for cost level heuristics.

It could also be used to flatten tail-call recursion.

> As the one that requested it, I have numerous uses for it to 
> mixin just the
> one level. I can't imagine any uses where I would ever want to 
> explicitly
> inline the whole tree, and not be happy to cascade it manually.

In innerloops to factor out common subexpressions that are 
otherwise recomputed over and over and over.

When the function is generated code (not hand written).

>> noninline_func(){ inline_func();}
>>
>
> Why? This is really overcomplicating a simple thing. And I'm 
> not quite sure
> what you're suggesting this should do either. Are you saying 
> the call tree
> is flattened behind this proxy non-inline function?

No, I am saying that the one level mixin doesn't provide you with 
anything new. You already have that. It is sugar.


More information about the Digitalmars-d mailing list