DIP56 Provide pragma to control function inlining
Joseph Cassman
jc7919 at outlook.com
Sun Feb 23 06:41:13 PST 2014
On Sunday, 23 February 2014 at 12:50:58 UTC, Walter Bright wrote:
> On 2/23/2014 4:38 AM, Dmitry Olshansky wrote:
>> Why pragma?
>
> Answered in another post.
>
>
>> Also how exactly it is supposed to work:
>
> T func(args)
> {
> ...
> pragma(inline, true);
> ...
> }
>
>
>> How to return to normal state then?
>
> Not necessary when it's inside a function.
>
>
>> I'd strongly favor introducing a compiler-hint family of UDAs
>> and
>> force_inline/force_notinline as first among many.
>
> I don't see an advantage of that over pragma. It also seems
> like something that should be inside a function, not outside.
> (After all, a function with no body cannot be inlined.)
Thanks for the code example. That helped me better understand
what is being proposed.
I like the idea of using pragma since it is built specifically
for the purpose of sending information to the compiler from code.
Also, I like not having to add another keyword to a function
definition. Especially since I already have "@safe pure nothrow"
in as many places as possible, for inline-able functions I'd
prefer to not have to add "inline" to that list. Using a pragma
would mean it could be implemented right away without worrying
about breaking any existing code. The proposal also satisfies the
needs of both parties. Especially since D is a flexible language
it would be nice to give such ability to customize code
generation to the programmer.
Given the above I think this is a good idea.
Joseph
More information about the Digitalmars-d
mailing list