Marking a delegate as pure, nothrow, etc.
John Colvin
john.loughran.colvin at gmail.com
Sun Apr 13 11:24:28 PDT 2014
On Sunday, 13 April 2014 at 18:10:19 UTC, Dicebot wrote:
> On Sunday, 13 April 2014 at 18:02:15 UTC, Joseph Rushton
> Wakeling wrote:
>> On 13/04/14 19:58, Joseph Rushton Wakeling wrote:
>>> Is it possible to mark a delegate as pure, @safe, nothrow,
>>> etc.? And if so, how?
>>
>> ... just answered my own question with a bit more
>> experimentation. The declarations need to come _after_ the
>> delegate:
>>
>> void foo(int delegate(int) @safe nothrow pure dg)
>> {
>> ...
>> }
>
> I'd actually recommend to put all function attributes after
> parameter list even for normal function declarations. It is not
> widely accepted practice but helps avoid some confusion:
>
> // `const` does not apply to return param here but to foo itself
> const int* foo() { return null; }
> // makes it obvious
> int* foo() const { return null; }
I agree. The only thing I put before the function is @property
More information about the Digitalmars-d-learn
mailing list