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

Reply via email to