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

Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Aug 15 10:18:02 PDT 2014


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?

Hmmm... It _should_ apply to everything, but maybe it only 
applies to the outer-level declarations. Certainly, in most 
cases, I'd be surprised if marking everything in a module with 
those attributes would work on the first go. It's _possible_, 
depending on what you're doing, but in my experience, odds are 
that you're doing _something_ that violates one or all of those 
in several places.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list