Improve this page Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone. Page wiki View or edit the community-maintained wiki page associated with this page.

Phobos Runtime Library

Phobos is the standard runtime library that comes with the D language compiler. Also, check out the wiki for Phobos.

Philosophy

Each module in Phobos conforms as much as possible to the following design goals. These are goals rather than requirements because D is not a religion, it's a programming language, and it recognizes that sometimes the goals are contradictory and counterproductive in certain situations, and programmers have jobs that need to get done.
Machine and Operating System Independent Interfaces
It's pretty well accepted that gratuitous non-portability should be avoided. This should not be construed, however, as meaning that access to unusual features of an operating system should be prevented.
Simple Operations should be Simple
A common and simple operation, like writing an array of bytes to a file, should be simple to code. I haven't seen a class library yet that simply and efficiently implemented common, basic file I/O operations.
Classes should strive to be independent of one another
It's discouraging to pull in a megabyte of code bloat by just trying to read a file into an array of bytes. Class independence also means that classes that turn out to be mistakes can be deprecated and redesigned without forcing a rewrite of the rest of the class library.
No pointless wrappers around C runtime library functions or OS API functions
D provides direct access to C runtime library functions and operating system API functions. Pointless D wrappers around those functions just adds blather, bloat, baggage and bugs.
Class implementations should use DBC
This will prove that DBC (Contract Programming) is worthwhile. Not only will it aid in debugging the class, but it will help every class user use the class correctly. DBC in the class library will have great leverage.
Use Exceptions for Error Handling
See Error Handling in D.

Imports

Runtime library modules can be imported with the import statement. Each module falls into one of several packages:
std
These are the core modules.

std.windows
Modules specific to the Windows operating system.

std.linux
Modules specific to the Linux operating system.

std.c
Modules that are simply interfaces to C functions. For example, interfaces to standard C library functions will be in std.c, such as std.c.stdio would be the interface to C's stdio.h.

std.c.windows
Modules corresponding to the C Windows API functions.

std.c.linux
Modules corresponding to the C Linux API functions.

etc
This is the root of a hierarchy of modules mirroring the std hierarchy. Modules in etc are not standard D modules. They are here because they are experimental, or for some other reason are not quite suitable for std, although they are still useful.


std: Core library modules

std.base64
Functions that operate on ASCII characters.
std.base64
Encode/decode base64 format.
std.bigint
Arbitrary-precision ('bignum') arithmetic
std.compiler
Information about the D compiler implementation.
std.conv
Conversion of strings to integers.
std.datetime
Date and time-related types and functions.
std.file
Basic file operations like read, write, append.
std.format
Formatted conversions of values to strings.
std.math
Include all the usual math functions like sin, cos, atan, etc.
std.md5
Compute MD5 digests.
std.mmfile
Memory mapped files.
object
The root class of the inheritance hierarchy
std.outbuffer
Assemble data into an array of bytes
std.path
Manipulate file names, path names, etc.
std.process
Create/destroy threads.
std.random
Random number generation.
std.regexp
The usual regular expression functions.
std.socket
Sockets.
std.socketstream
Stream for a blocking, connected Socket.
std.stdint
Integral types for various purposes.
std.stdio
Standard I/O.
std.cstream
Stream I/O.
std.stream
Stream I/O.
std.string
Basic string operations not covered by array ops.
std.system
Inquire about the CPU, operating system.
std.base64
Functions that operate on Unicode characters.
std.uri
Encode and decode Uniform Resource Identifiers (URIs).
std.utf
Encode and decode utf character encodings.
std.zip
Read/write zip archives.
std.zlib
Compression / Decompression of data.

std.windows: Modules specific to the Windows operating system

std.windows.syserror
Convert Windows error codes to strings.

std.linux: Modules specific to the Linux operating system


std.c: Interface to C functions

std.c.stdio
Interface to C stdio functions like printf().

std.c.windows: Interface to C Windows functions

std.c.windows.windows
Interface to Windows APIs

std.c.linux: Interface to C Linux functions

std.c.linux.linux
Interface to Linux APIs

std.c.stdio

int printf(char* format, ...)
C printf() function.