Dicebot:

Benefits: no arbitrary message length limit, no string construction unless toString is actually called.

A nothrow @nogc function like the bufferText I've suggested is also useful in situations like this (currently this can't compile):


struct Foo {
    int[3] data;

    ref int opIndex(in size_t i) pure nothrow @safe @nogc
    in {
        import std.string: format;
        assert(i < data.length,
               format("opIndex, %d >= %d", i, data.length));
    } body {
        return data[i];
    }
}

void main() {
    Foo f;
    auto r = f[10];
}


Bye,
bearophile

Reply via email to