pragma attribute syntax

Iain Buclaw ibuclaw at ubuntu.com
Mon Jun 4 14:49:51 PDT 2012


On 4 June 2012 21:53, Artur Skawina <art.08.09 at gmail.com> wrote:
> On 06/04/12 21:48, Iain Buclaw wrote:
>> On 4 June 2012 19:49, Artur Skawina <art.08.09 at gmail.com> wrote:
>>> Would it be possible to allow give the gcc attribute as a string?
>>> So that it would be possible to express 'pragma(attribute, align(8))' etc
>>>
>>> Because right now you can not do this:
>>>
>>>   pragma(attribute, pure)
>>>   pragma(attribute, const)
>
>> You can use underscores as alternate syntax:
>>
>> pragma(attribute, __pure__)
>> pragma(attribute, __const__)
>>
>
> Works, thank you.
>
> And it even does the right thing - makes the compiler correctly optimize
> away calls to pure functions that take const ref/pointer args, which D's
> "pure" does not handle yet.
>

To get the equivalent of "pure", you need to mark the function as pure
nothrow in D.  There is no equivalent of "const" yet, but we can
discuss ways to go about defining that. :)



-- 
Iain Buclaw

*(p < e ? p++ : p) = (c & 0x0f) + '0';


More information about the D.gnu mailing list