[Issue 9463] make @safe "non-escapable"
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Feb 6 17:28:47 PST 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9463
--- Comment #5 from Jonathan M Davis <jmdavisProg at gmx.com> 2013-02-06 17:28:46 PST ---
> But maybe there is a good solution, simply say that @safe is not applicable if > a function was previously marked @system or @trusted
That's what it does. The function in your example is @system, so the the fact
that there's an @safe block around it doesn't affect it.
> Yeah, but what if you can not trust the code you are mixing in to declare it
> self @safe, like in the example with the imported configuration. You could
> validate the code, by greping for @system and @trusted but this would be
> pretty unreliable, especially with mixins. So you would end up writing your
> own D parser.
Except that you should know what you're mixing in. And you probably shouldn't
be mixing in anything that you haven't written yourself. That's just asking for
it IMHO. And whether it's @safe or @trusted or whatever doesn't matter much
except to the caller, and the caller protects itself by marking itself @safe.
You'll then get a compilation error if a function isn't @safe like it's
supposed to be. And if you're mixing in code like that as part of your API (in
which case, the only way that you'd catch the problem would be unit testse),
then you should probably rethink your API anyway. Mixed in code doesn't appear
in the documentation.
And if your issue is with scripting, then you're not writing an API. You're
writing a script. So, you have full control over your code even if you don't
control the code that you're mixing in for some reason (as bad as that would
be), and anything @safe calling the functions will immediately give an error
for @system functions. In that case, the only ways an @system function wouldn't
be caught is if it's never used (in which case it doesn't matter) or if it's
called by another @system or @trusted function.
I honestly don't understand what you're doing that would require you to
validate that the functions being mixed and are @safe at the point that they're
mixed in. That validation will happen when they're used.
--
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