all OS functions should be "nothrow @trusted @nogc"

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Tue Jul 25 19:54:34 PDT 2017


On 7/25/2017 8:26 AM, Andrei Alexandrescu wrote:
> A suite of safe wrappers on OS primitives might be useful.

The idea of fixing the operating system interface(s) has come up now and then. 
I've tried to discourage that on the following grounds:


* We are not in the operating system business.

* Operating system APIs grow like weeds. We'd set ourselves an impossible task.

* It's a huge job simply to provide accurate declarations for the APIs.

* We'd have to write our own documentation for the operating system APIs. It's 
hard enough writing such for Phobos.

* A lot are fundamentally unfixable, like free() and strlen().

* The API import files should be focused solely on direct access to the APIs, 
not adding a translation layer. The user of them will expect this.

* We already have safe wrappers for the commonly used APIs. For read(), there is 
std.stdio.


It is worthwhile, however, to augment the APIs with the appropriate attributes 
like @nogc, scope, nothrow, @safe (for the ones that are), etc.


More information about the Digitalmars-d mailing list