H1 2015 Priorities and Bare-Metal Programming

Dicebot via Digitalmars-d digitalmars-d at puremagic.com
Tue Feb 3 09:29:22 PST 2015


On Tuesday, 3 February 2015 at 08:31:24 UTC, Walter Bright wrote:
> On 2/2/2015 8:36 PM, Daniel Murphy wrote:
>> The user can modify the code to allow it to be inlined.  There 
>> are a huge number
>> of constructs that cause dmd's inliner to completely give up.  
>> If a function
>> _must_ be inlined, the compiler needs to give an error if it 
>> fails.
>
> A separate message with a pragmatic difficulty with your 
> suggestion.
>
> Different compilers will have different inlining capabilities. 
> Different versions of the same compiler may behave differently. 
> This means that sometimes a user may get a compilation failure, 
> sometimes not. It's highly brittle.

This is _exactly_ why error message is needed. Considering
compiler differences and with all inlining bugs in mind it is
impossible for developer to reason if certain code will be
inlined and rely on it in any fashion.

For most programs it is mere inconvenience. For something
low-level like embedded programming it can become a deal-breaker
making the difference between working and broken program.

> So enter the workaround code. Different compilers and different 
> versions will require different workaround code. Is this really 
> reasonable for users to put up with?

Yes, and this is very good as it will ensure that feature won't
be abused in "normal" programs because it is so hard to deal
with. But in barebone world it is very common to develop
exclusively for one specific compiler version so it won't be a
problem.

> And will they really want to be running the workaround code 
> when they upgrade the compiler and now it could have inlined it?

No, they will really want to not use this feature. Because it has
different niche.

To sum it up, I don't think your proposal is bad on its own - it
simply tries to solve different problems than ones being asked.
Manu problem is a different problem than Johannes has - but you
seem to consider those identical.

Why can't we simply have 3 cases for pragma?

pragma(inline, never);  // not even with -inline
pragma(inline, always); // even without -inline
pragma(inline, force);  // error if can't inline


More information about the Digitalmars-d mailing list