Marking a delegate as pure, nothrow, etc.

monarch_dodra monarchdodra at gmail.com
Sun Apr 13 11:36:13 PDT 2014


On Sunday, 13 April 2014 at 18:31:07 UTC, Joseph Rushton Wakeling 
wrote:
> On 13/04/14 20:28, Joseph Rushton Wakeling wrote:
>> On 13/04/14 20:10, Dicebot wrote:
>>> 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
>>
>> It's actually my habitual practice
>
> Incidentally, for _exactly_ the reason you describe.  Early in 
> my D life I got quite confused over the need to write,
>
>     const(int) foo() { ... }
>
> and not
>
>     const int foo() { ... }
>
> and putting function attributes after is _really_ helpful in 
> avoiding unhelpful and incorrect comparisons to C/C++ 
> declarations.

Yeah, but then again, putting them first helpful in noticing that 
you accidentally wrote it wrong:
//I see anyting wrong here?
const int foo() @safe pure nothrow { ... }

//How about now?
@safe pure nothrow const int foo() { ... }

Personally, I like placing everything on its own line, before.


More information about the Digitalmars-d-learn mailing list