@safe, pure and nothrow at the beginning of a module

Philpax via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Aug 15 20:25:11 PDT 2014


On Friday, 15 August 2014 at 23:22:27 UTC, Vlad Levenfeld wrote:
> On Friday, 15 August 2014 at 16:54:54 UTC, Philippe Sigaud 
> wrote:
>> So I'm trying to use @safe, pure and nothrow.
>>
>> If I understand correctly Adam Ruppe's Cookbook, by putting
>>
>> @safe:
>> pure:
>> nothrow:
>>
>> at the beginning of a module, I distribute it on all 
>> definitions, right? Even methods, inner classes, and so on?
>>
>> Because I did just that on half a dozen of modules and the 
>> compiler did not complain. Does that mean my code is clean(?) 
>> or that what I did has no effect?
>
> I've noticed the same thing. If I want pure and nothrow to 
> propage to inner structs and classes I have to place another 
> label inside the class definition. Otherwise only free 
> functions are affected.

I had a similar experience when trying to use @nogc. Having to 
insert @nogc into every struct I use is mildly annoying.



More information about the Digitalmars-d-learn mailing list