Is memory-safe IO possible?

Brad Roberts via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jan 22 11:15:58 PST 2016


On 1/22/2016 9:10 AM, Chris Wright via Digitalmars-d-learn wrote:
> On Fri, 22 Jan 2016 08:36:14 +0000, Kagamin wrote:
>
>> Should be possible. Why not?
>
> Because almost no IO routines in Phobos are marked @safe, which implies
> that it's difficult in practice or that people simply haven't done it. I
> checked std.file, std.net.curl, and std.stdio; a handful of things are
> @safe while the vast majority aren't.
>
> I want everything I do to be @safe. Unfortunately, "everything I do"
> includes IO (and std.json), and while it's not sprinkled throughout my
> code, the call stack has enough variety that I can't mark very much @safe
> at the end of the day.
>
> At the very least, it would be nice to say: I can't entirely trust some
> of the code I'm calling, but at least for the code I'm writing here, stop
> me from doing anything stupid. A @tryToBeSafeIsh, if you will.

Correct, the bug isn't that the documentation is missing about why it's 
not @safe.  The bug is that a whole lot of phobos (and druntime) should 
be @safe but the work hasn't been done to mark it as such.  At this 
point in time, there's not many interesting apps that could mark their 
main with @safe, which is a real shame.


More information about the Digitalmars-d-learn mailing list