digitalmars.D.learn - Is there a way to clear an OutBuffer?
- Jon Degenhardt (5/5) May 22 2016 Is there a way to clear an OutBuffer, but without freeing the
- =?UTF-8?Q?Ali_=c3=87ehreli?= (15/20) May 22 2016 Currently not possible. Enhancement request perhaps?
- Jon Degenhardt (3/27) May 22 2016 Thanks. Enhancement request:
- Seb (4/30) May 23 2016 It was once proposed to have start & stop, which could also imply
- Gary Willoughby (3/25) May 25 2016 Is there a consensus on this? Does this really need a clear
- Jon Degenhardt (9/35) May 25 2016 As an end-user, I'd have more confidence using a documented
Is there a way to clear an OutBuffer, but without freeing the internally managed buffer? Something similar to std.array.appender.clear method. Intent would be to reuse the OutBuffer, but without reallocating memory for the buffer. --Jon
May 22 2016
On 05/22/2016 11:59 AM, Jon Degenhardt wrote:Is there a way to clear an OutBuffer, but without freeing the internally managed buffer? Something similar to std.array.appender.clear method. Intent would be to reuse the OutBuffer, but without reallocating memory for the buffer. --JonCurrently not possible. Enhancement request perhaps? Looking at the implementation, setting its 'offset' member seems to work. Based on example from documentation: import std.outbuffer; void main() { OutBuffer b = new OutBuffer(); b.writefln("a%sb", 16); assert(b.toString() == "a16b\n"); b.offset = 0; b.writefln("a%sb", 16); assert(b.toString() == "a16b\n"); } Bug report perhaps? :) Ali
May 22 2016
On Sunday, 22 May 2016 at 23:01:07 UTC, Ali Çehreli wrote:On 05/22/2016 11:59 AM, Jon Degenhardt wrote:Thanks. Enhancement request: https://issues.dlang.org/show_bug.cgi?id=16062Is there a way to clear an OutBuffer, but without freeing the internally managed buffer? Something similar to std.array.appender.clear method. Intent would be to reuse the OutBuffer, but without reallocating memory for the buffer. --JonCurrently not possible. Enhancement request perhaps? Looking at the implementation, setting its 'offset' member seems to work. Based on example from documentation: import std.outbuffer; void main() { OutBuffer b = new OutBuffer(); b.writefln("a%sb", 16); assert(b.toString() == "a16b\n"); b.offset = 0; b.writefln("a%sb", 16); assert(b.toString() == "a16b\n"); } Bug report perhaps? :) Ali
May 22 2016
On Monday, 23 May 2016 at 03:03:12 UTC, Jon Degenhardt wrote:On Sunday, 22 May 2016 at 23:01:07 UTC, Ali Çehreli wrote:It was once proposed to have start & stop, which could also imply that it's resettable: https://github.com/dlang/phobos/pull/3362On 05/22/2016 11:59 AM, Jon Degenhardt wrote:Thanks. Enhancement request: https://issues.dlang.org/show_bug.cgi?id=16062[...]Currently not possible. Enhancement request perhaps? Looking at the implementation, setting its 'offset' member seems to work. Based on example from documentation: import std.outbuffer; void main() { OutBuffer b = new OutBuffer(); b.writefln("a%sb", 16); assert(b.toString() == "a16b\n"); b.offset = 0; b.writefln("a%sb", 16); assert(b.toString() == "a16b\n"); } Bug report perhaps? :) Ali
May 23 2016
On Monday, 23 May 2016 at 03:03:12 UTC, Jon Degenhardt wrote:Is there a consensus on this? Does this really need a clear method seeing as though you can reset the offset directly?Currently not possible. Enhancement request perhaps? Looking at the implementation, setting its 'offset' member seems to work. Based on example from documentation: import std.outbuffer; void main() { OutBuffer b = new OutBuffer(); b.writefln("a%sb", 16); assert(b.toString() == "a16b\n"); b.offset = 0; b.writefln("a%sb", 16); assert(b.toString() == "a16b\n"); } Bug report perhaps? :) AliThanks. Enhancement request: https://issues.dlang.org/show_bug.cgi?id=16062
May 25 2016
On Wednesday, 25 May 2016 at 19:42:43 UTC, Gary Willoughby wrote:On Monday, 23 May 2016 at 03:03:12 UTC, Jon Degenhardt wrote:As an end-user, I'd have more confidence using a documented mechanism. If it's setting a public member variable, fine, if it's a method, also fine. The 'offset' member is not part of the publicly documented API. Looking at the implementation, it doesn't appear 'offset' is intended to be part of the API. Personally, I'd add a method to keep 'offset' out of the public API. However, simply documenting it is an option as well.Is there a consensus on this? Does this really need a clear method seeing as though you can reset the offset directly?Currently not possible. Enhancement request perhaps? Looking at the implementation, setting its 'offset' member seems to work. Based on example from documentation: import std.outbuffer; void main() { OutBuffer b = new OutBuffer(); b.writefln("a%sb", 16); assert(b.toString() == "a16b\n"); b.offset = 0; b.writefln("a%sb", 16); assert(b.toString() == "a16b\n"); } Bug report perhaps? :) AliThanks. Enhancement request: https://issues.dlang.org/show_bug.cgi?id=16062
May 25 2016