The Wayback Machine - https://web.archive.org/web/20140809130157/http://dlang.org/phobos/
Improve this pageQuickly 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 usinglocal clone.Page wikiView or edit the community-maintained wiki page associated with this page. Phobos Runtime Library
Phobos is the standard runtime library that comes with theD language compiler. Also, check out the
wiki for Phobos.
Philosophy
Each module in Phobos conforms as much as possible to thefollowing design goals. These are goalsrather than requirements because D is not a religion,it's a programming language, and it recognizes thatsometimes the goals are contradictory and counterproductivein certain situations, and programmers havejobs that need to get done.
- Machine and Operating System Independent Interfaces
- It's pretty well accepted that gratuitous non-portabilityshould be avoided. This should not beconstrued, however, as meaning that access to unusualfeatures of an operating system should be prevented.
- Simple Operations should be Simple
- A common and simple operation, like writing an array ofbytes to a file, should be simple tocode. I haven't seen a class library yet that simply and efficientlyimplemented 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 bloatby just trying to read a file into an array ofbytes. Class independence also means that classes that turnout to be mistakes can be deprecated and redesigned withoutforcing 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 functionsand 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, butit will help every class user use the class correctly.DBC in the class library will have great leverage.
- Use Exceptions for Error Handling
- SeeError Handling in D.
Imports
Runtime library modules can be imported with the
import statement. Each module falls into one of severalpackages:
- 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 functionswill be in std.c, such as std.c.stdio would be the interfaceto 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 stdhierarchy. Modules in etc are not standard D modules. They arehere because they are experimental, or for some other reason arenot quite suitable for std, although they are still useful.
std: Core library modules
- std.ascii
- 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.regex
- The usual regular expression functions.
- std.socket
- Sockets.
- std.socketstream
- Stream for a blocking, connectedSocket.
- 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
- intprintf(char* format, ...)
- C printf() function.