Re: Some @nogc text conversion in Phobos?

2014-05-31 Thread bearophile via Digitalmars-d
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

Re: Some @nogc text conversion in Phobos?

2014-05-29 Thread Dmitry Olshansky via Digitalmars-d
29-May-2014 03:52, Dicebot пишет: On Wednesday, 28 May 2014 at 23:27:34 UTC, bearophile wrote: This is currently accepted code: [] IMHO something like this is better: class MyException : Exception { private char[20] index_buff; // should be enough for size_t.max Why not just save

Re: Some @nogc text conversion in Phobos?

2014-05-29 Thread Dicebot via Digitalmars-d
On Thursday, 29 May 2014 at 18:30:28 UTC, Dmitry Olshansky wrote: 29-May-2014 03:52, Dicebot пишет: On Wednesday, 28 May 2014 at 23:27:34 UTC, bearophile wrote: This is currently accepted code: [] IMHO something like this is better: class MyException : Exception { private char[20]

Some @nogc text conversion in Phobos?

2014-05-28 Thread bearophile via Digitalmars-d
This is currently accepted code: void main() { import std.array: appender; import std.format: formattedWrite; auto writer = appender!string; formattedWrite(writer, %s is the ultimate %s., 42, answer); assert(writer.data == 42 is the ultimate answer.); } But there are

Re: Some @nogc text conversion in Phobos?

2014-05-28 Thread Dicebot via Digitalmars-d
On Wednesday, 28 May 2014 at 23:27:34 UTC, bearophile wrote: This is currently accepted code: void main() { import std.array: appender; import std.format: formattedWrite; auto writer = appender!string; formattedWrite(writer, %s is the ultimate %s., 42, answer);