Thread overview
Something similar to "inline"
Dec 27
tososdk
Dec 27
Johan
December 27

Two things: Could you explain how "inline" works? Is there something similar in Dlang?

December 27

On Wednesday, 27 December 2023 at 15:57:14 UTC, tososdk wrote:

>

Two things: Could you explain how "inline" works? Is there something similar in Dlang?

In C and C++, inline is a suggestion to the compiler that it should consider using inline expansion for calls to a particular function. However, the compiler is free to ignore this suggestion, and is also free to use inline expansion for functions that are not marked with inline.

In D, the closest equivalent is pragma(inline), which can be used to enable or disable inline expansion for a particular function. With pragma(inline, true), the function will always be expanded inline; with pragma(inline, false), it will never be expanded.

December 27

On Wednesday, 27 December 2023 at 16:35:47 UTC, Paul Backus wrote:

>

On Wednesday, 27 December 2023 at 15:57:14 UTC, tososdk wrote:

>

Two things: Could you explain how "inline" works? Is there something similar in Dlang?

I don't think the D forums is the best place to ask about how "inline" works, when you mean another "inline" than what is available in D...

>

In C and C++, inline is a suggestion to the compiler that it should consider using [inline expansion][1] for calls to a particular function. However, the compiler is free to ignore this suggestion, and is also free to use inline expansion for functions that are not marked with inline.

inline in C/C++ is only vaguely related to inline expansion. Its meaning is related to linkage, allowing multiple definitions of that symbol. https://en.cppreference.com/w/cpp/language/inline
Dlang does not have something similar.

-Johan