What does 'inline' mean?

Manu turkeyman at gmail.com
Tue Jun 9 01:40:38 UTC 2020


On Tue, Jun 9, 2020 at 11:30 AM Stanislav Blinov via Digitalmars-d <
digitalmars-d at puremagic.com> wrote:

> On Tuesday, 9 June 2020 at 00:36:18 UTC, Manu wrote:
>
> > What's funny is, in most cases, whether the function is
> > ACTUALLY inlined is
> > not really interesting in 2020.
> > What inline allows is control over the binary environment as I
> > describe. I
> > read it these days as "inline to the calling CU" rather than
> > "inline to the
> > calling function".
> >
> > There are cases where inline is really important, and I do want
> > an error if it fails; for instance, if you have a leaf function
> > (does not allocate any stack memory), it's only possible to
> > make calls from that function where the callee is inlined...
> > and if inlining fails, your caller will lose its no-stack-frame
> > requirement. I've had this come up numerous times, and in those
> > cases, a really-strong-does-make-compile-error inline would be
> > useful, but C++ doesn't have anything like that.
>
> Maybe it's a case where a clear disambiguation is in order? E.g.
> make a new
>
> pragma(local);
>
> ...which would instruct the compiler to do what you're
> describing. Or, perhaps, expand the range of options for the
> existing pragma(inline), from the current bool to an enum of
> behaviors.
>

I've suggested that before, and I think that's what I'd encourage:
  pragma(inline, never) do not inline
  pragma(inline, true) like C/C++, emit to calling CU, hint preference the
optimiser (if it is capable of receiving hints)
  pragma(inline, force) same as true, but error when it fails
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20200609/de3a6c2e/attachment.htm>


More information about the Digitalmars-d mailing list