Library Introduction

The D standard library is an extensible framework which contains components for language support, string processing, input/output, containers, algorithms, etc. Language support components are required for features such as memory allocation, exceptions, and built-in UTF transcoding.

Language Support Library

This section describes functions that are called implicitly, and types that are fundamental to the D language.

Types

Blah blah.

Module [std.c.stddef] synopsis

    Types:
        size_t
        ptrdiff_t
        wint_t
        wchar_t
        wctype_t
        wctrans_t

    Constants:
        WEOF

The size and type of these symbols are equivalent to the standard C/C++ symbols with the same name. This module is roughly equivalent to the standard C header <stddef.h> but has been expanded to include wide character types and constants as well.

Module [object] synopsis

    class Object;
    struct Interface;
    class TypeInfo;
    class ClassInfo;
    class Exception;

Class Object

    class Object
    {
        void print();
        char[] toString();
        uint toHash();
        int opCmp(Object obj);
        int opEquals(Object obj);
    }

Struct Interface

    struct Interface
    {
        ClassInfo   classinfo;
        void*[]     vtbl;
        int         offset;
    }

Class TypeInfo

    class TypeInfo
    {
        uint toHash();
        int opCmp(Object o);
        int opEquals(Object o);
        uint getHash(void *p);
        int equals(void *p1, void *p2);
        int compare(void *p1, void *p2);
        int tsize();
        void swap(void *p1, void *p2);
    }

Class ClassInfo

    class ClassInfo
    {
        byte[]      init;
        char[]      name;
        void*[]     vtbl;
        Interface[] interfaces;
        ClassInfo   base;
        void*       destructor;
        void(*classInvariant)(Object);
        uint        flags;
        void*       deallocator;
    }

Class Exception

    class Exception
    {
        char[] msg;
        this(char[] msg);
        void print();
        char[] toString();
    } 
Blah blah.

Exception Handling

Blah blah.

Module  [std.error] synopsis

    class AssertError;
    class OutOfMemoryError;
    class ArrayBoundsError;
    class SwitchError;
    class InvalidUtfError;

    void setAssertHandler( void function( char[] file, uint line ) );

    extern (C) void onAssert( char[] file, uint line );
    extern (C) void onOutOfMemory();
    extern (C) void onArrayBoundsError( char[] file, uint line );
    extern (C) void onSwitchError( char[] file, uint line );
    extern (C) void onInvalidUtfError( char[] msg, size_t idx );

Class AssertError

    class AssertError
    {
        char[]  file;
        uint    line;

        this( char[] file, uint line );
        void print();
    }

Class OutOfMemoryError

    class OutOfMemoryError
    {
        char[]  file;
        uint    line;

        this( char[] file, uint line );
        void print();
    }

Class ArrayBoundsError

    class ArrayBoundsError
    {
        char[]  file;
        uint    line;

        this( char[] file, uint line );
        void print();
    }

Class SwitchError

    class SwitchError
    {
        char[]  file;
        uint    line;

        this( char[] file, uint line );
        void print();
    }

Class InvalidUtfError

    class InvalidUtfError : Exception
    {
        size_t idx;

        this( char[] msg, size_t idx );
    }

setAssertHandler

    void setAssertHandler( void function( char[] file, uint line ) );

Sets a user defined assert handler that will be called on an assertion failure.

onAssert

    extern (C) void onAssert( char[] file, uint line );

onOutOfMemory

    extern (C) void onOutOfMemory();

onArrayBoundsError

    extern (C) void onArrayBoundsError( char[] file, uint line );

onSwitchError

    extern (C) void onSwitchError( char[] file, uint line );

onInvalidUtfError

    extern (C) void onInvalidUtfError( char[] msg, size_t idx );

These functions are designed to facilitate library interaction. Each is expected to be called when its respective event occurs.  If a handler is mapped via a setHandler routine then that function should be called, otherwise the

Threading

Module [std.thread] synopsis

class ThreadError;
class Thread;

Class ThreadError

class ThreadError : Exception
{
    this( char[] msg );
}

Class Thread

class Thread
{
    this();
    this( void function() fn );
    this( void delegate() dg );
    ~this();
    
    final char[] name();
    final void name( char[] n );
    final void start();
    final bit isRunning();
    final void join();
    final void suspend();
    final void resume();
    final void* stackHead();
    final void* stackTail();
    final void* regHead();
    final void* regTail();

    static this();
    static ~this();

    static void sleep( uint milliseconds );
    static void yield();
    static size_t count();
    static void suspendAll();
    static void resumeAll();
    static Thread getThis();
    static Thread[] getAll();
    static int opApply( int delegate( inout Thread ) dg );

protected:
    void run();
}

Note that some static members of this class are required by the garbage collector and therefore must operate correctly without dynamic memory allocation and may be called before the module's static ctor has been run.