force inline/not-inline

Brandon Ragland via Digitalmars-d digitalmars-d at puremagic.com
Tue Jul 28 16:54:58 PDT 2015


On Tuesday, 28 July 2015 at 21:28:30 UTC, Steven Schveighoffer 
wrote:
> On 7/28/15 5:24 PM, David Nadlinger wrote:
>> On Tuesday, 28 July 2015 at 15:56:52 UTC, Jonathan M Davis 
>> wrote:
>>> It[Accepting Booleans]'s far more flexible in generic code.
>>
>> It's the other way round. pragma(inline) has currently *three* 
>> behaviors:
>>
>> pragma(inline);
>> pragma(inline, true);
>> pragma(inline, false);
>>
>> There is no way to represent those as a single boolean.
>
> Ugh. And pragma(inline) doesn't mean what you would think it 
> means. This is not a very good API for it, it's going to 
> confuse everyone.
>
> -Steve

I don't think it's terrible confusing, just deceptive.

If pragma(inline) means "attempt to inline just like the -inline 
compile time attribute" then it's just an ugly way of repeating 
yourself.

In my opinion it shouldn't be any kind of expression. How often 
will ever need evaluate an expression for inlining? The hint: 
Once in 3 programmer's lifetimes.

It should be something like:

@inline @noinline

Or some other pragma or attribute.

If I want inlining, I want inlining. If the compiler cannot 
inline, throw an exception. Otherwise, do as I ask. I'm not here 
to joke around with a compiler. I'm here to develop my programs 
and have the compiler be on my side, not against me.


More information about the Digitalmars-d mailing list