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 LibraryPhobos is the standard runtime library that comes with the D language compiler. Also, check out the wiki for Phobos.
PhilosophyEach 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.
ImportsRuntime library modules can be imported with the import statement. Each module falls into one of several packages:
- These are the core modules.
- Modules specific to the Windows operating system.
- Modules specific to the Linux operating system.
- 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.
- 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
- Functions that operate on ASCII characters.
- Encode/decode base64 format.
- Arbitrary-precision ('bignum') arithmetic
- Information about the D compiler implementation.
- Conversion of strings to integers.
- Date and time-related types and functions.
- Basic file operations like read, write, append.
- Formatted conversions of values to strings.
- Include all the usual math functions like sin, cos, atan, etc.
- Compute MD5 digests.
- Memory mapped files.
- The root class of the inheritance hierarchy
- Assemble data into an array of bytes
- Manipulate file names, path names, etc.
- Create/destroy threads.
- Random number generation.
- The usual regular expression functions.
- Stream for a blocking, connected Socket.
- Integral types for various purposes.
- Standard I/O.
- Stream I/O.
- Stream I/O.
- Basic string operations not covered by array ops.
- Inquire about the CPU, operating system.
- Functions that operate on Unicode characters.
- Encode and decode Uniform Resource Identifiers (URIs).
- Encode and decode utf character encodings.
- Read/write zip archives.
- Compression / Decompression of data.
std.windows: Modules specific to the Windows operating system
- Convert Windows error codes to strings.
std.linux: Modules specific to the Linux operating system
std.c: Interface to C functions
- Interface to C stdio functions like printf().
std.c.windows: Interface to C Windows functions
- Interface to Windows APIs
std.c.linux: Interface to C Linux functions
- Interface to Linux APIs
- int printf(char* format, ...)
- C printf() function.