What does 'inline' mean?

Stefan Koch uplink.coder at googlemail.com
Tue Jun 9 09:47:13 UTC 2020


On Tuesday, 9 June 2020 at 09:29:47 UTC, Walter Bright wrote:
> On 6/8/2020 7:09 AM, Manu wrote:
>> No, actually... it's not. It's not an 'optimisation' in any 
>> case except maaaaybe #2; it's about control of the binary 
>> output and code generation.
>
> Inlining is 100% about optimization.
>

We are not talking about inlining.

The whole idea behind this thread is to explain that, c++ use of 
"inline" does not actually mean that a function is to be inlined.

What we are talking about is a non-hacky way to say, I want a 
copy of this function in my object file, regardless of the module 
it was defined in.

You _can_ get the same effect by doing this:
---
string I_need_this_function()(string x)
{
     return "x: " ~ x;
}
---

But that introduces a template which comes with another set of 
problems.
Such that you don't get type-checking of the body if it's not 
used.




More information about the Digitalmars-d mailing list