Is there a way to clear an OutBuffer?

Jon Degenhardt via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed May 25 22:40:49 PDT 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:
>>> 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
>>
>> Thanks. Enhancement request: 
>> https://issues.dlang.org/show_bug.cgi?id=16062
>
> Is there a consensus on this? Does this really need a clear 
> method seeing as though you can reset the offset directly?

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.



More information about the Digitalmars-d-learn mailing list