On 31 July 2015 at 14:06, Steven Schveighoffer via Digitalmars-d < digitalmars-d@puremagic.com> wrote:
> On 7/30/15 4:37 PM, Jonathan M Davis wrote: > >> On Thursday, 30 July 2015 at 18:41:51 UTC, Steven Schveighoffer wrote: >> >>> OK, that is what I first thought. Then I thought it meant that for >>> that function, it works as if -inline was passed on the command line >>> (i.e. try to inline if possible, if not, don't worry about it). So you >>> are saying the first interpretation is correct? >>> >>> That means pragma(inline) is essentially useless. >>> >> >> Well, if pragmas work with : like attributes (I don't know if they do), >> then pragma(inline) would be a way to undo a pragma(inline, true) or >> pragma(inline, false) on specific functions, similar to how many folks >> want !final or final(false) after using final:, but if : doesn't work >> with pragmas, then yeah, it's totally useless. >> > > Without knowing the rules what does this do: > > pragma(inline): > int foo() > { > return 1; > } > > If anyone reads this and says he intuitively thinks "oh, that will mean > you have to pass -inline on the command line to get it inlined," I think he > is not being truthful. > > -Steve > Yeah... I'm sticking to my earlier assertion on this. Using -(f)inline on the command line should not be read as being related to pragma(inline). The pragma is explicit request by the user which says that this function should be inlined. So the way I read it, is that uninlineable functions marked with pragma(inline) should come with whatever diagnostics necessary to heed off the user from using it in situations that are impossible. When I say this, I mean things like: - Naked functions - Functions with D-style asm - Functions with calls to alloca() - Variadic functions With everything else, you can either expect the function to be inlined... or not - it really does depend on whether or not the compiler sees it as worth it, but at least you don't get errors about it. It's at this point that pragma(inline, true) comes into the picture. Regards Iain.