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

Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Aug 16 12:29:08 PDT 2014


On Sat, 16 Aug 2014 14:39:00 +0200
Artur Skawina via Digitalmars-d-learn
<digitalmars-d-learn at puremagic.com> wrote:

> On 08/16/14 13:58, Philippe Sigaud via Digitalmars-d-learn wrote:
> > On Sat, Aug 16, 2014 at 1:30 PM, Artur Skawina via
> > Digitalmars-d-learn
>
> >> http://forum.dlang.org/post/mailman.125.1397731134.2763.digitalmars-d@puremagic.com
> >
> > Okay...
> >
> > So @safe includes child scopes. I suppose @trusted and @system work
> > in the same way.
> >
> > *but*
> >
> > nothrow, @nogc and UDA's do not include child scopes. Putting them
> > at the beginning of a module will not affect methods in
> > aggregates...
> >
> > What's the situation for pure? (I don't have a D compiler handy
> > right now, or I would test it myself).
>
> @safe, @trusted, @system, shared, immutable, const, inout and `extern
> (...)` affect child scopes. `synchronized` does too, but in a rather
> unintuitive way; hopefully nobody uses this. ;)
>
> Other attributes, including 'pure' and 'nothrow' only affect symbols
> in the current scope.

It sounds like a bug to me if they're not consistent.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list