[Issue 6193] New: Appender.clear() functionality or documentation

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jun 21 16:17:30 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=6193

           Summary: Appender.clear() functionality or documentation
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 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;
    foo.put('a');
    foo.clear();
}


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;
    foo.put('a');
    foo.clear();
}



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: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list