[Issue 9463] make @safe "non-escapable"

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Feb 6 15:36:35 PST 2013


http://d.puremagic.com/issues/show_bug.cgi?id=9463


Jonathan M Davis <jmdavisProg at gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jmdavisProg at gmx.com


--- Comment #3 from Jonathan M Davis <jmdavisProg at gmx.com> 2013-02-06 15:36:34 PST ---
The only difference between using : and {} with attributes is that {} has an
end to its scope, whereas : only ends if it's overriden by a conflicting
attribute. Differentiating between the two in terms of what they affect seems
like a really bad idea to me.

I'd argue that it's up to the functions being mixed in to guarantee that
they're @safe, not the code that's mixing them in. And attributes get ignored
all the time if they don't apply. Relying on attributes which are applied
globally with : or {} is often a bad idea precisely because dmd will happily
ignore attributes that it doesn't think are applicable.

> I personally would prefer the simple consistent rule, that you can not weaken
> @safe, @trusted once you declared it. If you don't want the whole file @safe,
> then don't say so.

Except that that's always up to the function. You can't weaken @safe because it
was never applied in the first place. All that attribute{} or attribute: do is
mark symbols with those attributes if applicable, and it doesn't apply if
there's a conflicting attribute. The same happens with access levels.

private {
public int foo() { return 42; }
}

dmd quite happily makes foo public. There generally are no special cases with
attributes in D (and I can't think of _any_ at the moment). If there were, it
would be required to put const on the right-hand side of a function rather than
the left (due to the confusion it causes by being on the left, since it looks
like it applies to the return type when it doesn't), but Walter refuses to
special case attributes like that. They're all treated the same on purpose. And
I think that it would be a mistake to treat @safe or @system any differently
from the rest.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list