Summary: Appender.clear() functionality or documentation
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos

--- Comment #0 from 2011-06-21 16:12:43 PDT ---
This is an enhancement request, or (because I am often mistaken) it's just an
enhancement request for the documentation.

This program works with DMD 2.053:

import std.stdio;
void main() {
    string foo = "abc";
    foo ~= 'a';
    foo.length = 0;

This other program too runs:

import std.array: Appender;
void main() {
    Appender!(char[]) foo;

But this gives an error:
temp.d(5): Error: no property 'clear' for type 'Appender!(string)'

import std.array: Appender;
void main() {
    Appender!string foo;

Strings are made of immutable chars, but you are allowed to clear (set the
length to zero) a string. So I expect Appender to allow the same.

If this not a good thing, then I suggest to add to the online docs of the
std.array.Appender.clear() method a note that explains it is present
(compiled-in) only in certain cases. Because currently I haven't seen a mention
of this, and the error message given by the compiler doesn't explain enough.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to