[Issue 14125] @trusted nested helper functions in std.file
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Wed Feb 4 21:38:24 PST 2015
https://issues.dlang.org/show_bug.cgi?id=14125
--- Comment #61 from Andrei Alexandrescu <andrei at erdani.com> ---
(In reply to David Nadlinger from comment #59)
> (In reply to Andrei Alexandrescu from comment #53)
> > (In reply to David Nadlinger from comment #51)
> > > (In reply to Andrei Alexandrescu from comment #42)
> > > > Sigh, std.array has become another disaster area we need to clean.
> > >
> > > What about just giving it a try?
> >
> > Give what a try? The cleanup?
>
> Yes. Or think about why e.g. marking a template function that iterates over
> a range @trusted in its entirety would be almost always wrong, at least
> without explicitly constraining the range regarding @safe-ty of its
> primitives.
>
> To me, it seems rather obvious that @trusted blocks would be A Good Thing.
> To you and/or Walter, it seems to be clear that they are The Root of All
> Evil.
I just think they'd be more open to misuse and abuse. I do agree they can be
used well, too.
> I figure it would save us a lot of discussion if you had a look at
> real-world code where their conceptual equivalent is useful right now.
Well I just did - std.file does count for real-world code. It's just not right.
> (Just to be clear: Yes, nested functions that just pretend to be safe are
> ugly, but immediately invoked delegates or real @trusted blocks aren't an
> option right now. It's the concept that is important here.)
The concept is: best use of @trusted is to mark a safe function that cannot be
automatically proven @safe. All that wrapping realloc as trustedRealloc and
then cheering that we got safe code going is nonsense.
--
More information about the Digitalmars-d-bugs
mailing list