[Issue 14125] std.file has gotten out of hand

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Feb 4 18:04:19 PST 2015


https://issues.dlang.org/show_bug.cgi?id=14125

--- Comment #33 from Walter Bright <bugzilla at digitalmars.com> ---
(In reply to hsteoh from comment #28)
> But still, the nagging issue is, how do we restrict the scope of @trusted
> inside a function body?

By encapsulating the unsafe part in an @trusted local function. But that
function must STILL present a safe interface. Merely wrapping it with "here is
an unsafe operation" may fly with other languages, but it is not acceptable in
D.

Apply this rule:

"If the compiler cannot verify memory safety in code marked @safe, then you did
it wrong."

This code, for example, flunks that rule:

  static trustedCloseHandle(HANDLE hObject) @trusted
  {
    return CloseHandle(hObject);
  }

--


More information about the Digitalmars-d-bugs mailing list