DIP56 - inlining

Iain Buclaw via Digitalmars-d digitalmars-d at puremagic.com
Wed Feb 4 00:11:40 PST 2015


On 4 February 2015 at 07:16, ketmar via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
> On Wed, 04 Feb 2015 06:59:52 +0000, Ola Fosheim Grøstad wrote:
>
>> On Wednesday, 4 February 2015 at 05:20:30 UTC, ketmar wrote:
>>> there. i still can't see what's wrong with `@attribute("inline")`,
>>> `@attribute("force_inline")` and so on. ah, except it breaks one of the
>>> first rules in The Book Of D: "try to escape uniformity whenever it is
>>> possible".
>>
>> Using pragmas for inlining is common in compilers for other clean
>> languages (Ada, Haskell).
>>
>> Unless inlining affects the ability to use functions as actual
>> parameters it is not part of the language and therefore a pragma,
>> but I agree that the pragma syntax is ugly, but "@attribute" is also
>> ugly.
>>
>> Maybe better to reserve "@_word" so that they cannot be used for UDA and
>> let all pragmas start with "@_":
>>
>> @_inline(0) // never, inline_weight*0 => 0 @_inline(1) // default,
>> inline_weight*1 => inline_weight @_inline(Inf) // always,
>> inline_weight*Inf => Inf @_inline       // same as @_inline(Inf)
>
> using `@attribute("...")` is ugly, but it has the advantage of simple
> workarounding for compilers that still not supporting that attribute.

You can tell the compiler to ignore unknown pragmas too...



More information about the Digitalmars-d mailing list