Steven Schveighoffer <> changed:

           What    |Removed                     |Added
             Status|NEW                         |ASSIGNED
         AssignedTo|        |
           Severity|enhancement                 |minor

--- Comment #1 from Steven Schveighoffer <> 2011-06-22 
06:02:18 PDT ---
It is intentionally missing from Appender when the data type is immutable or
const.  See the code here:

The issue is because Appender owns the data it's appending to, clearing the
data will *reuse* the buffer to do appending again.  But this would violate the
requirements for immutable.  This is different from setting a slice length to
0, because a slice *does not own* the data.  Appending to a slice whose length
was set to 0 would allocate a *new* block to append into.

The equivalent slice code for Appender.clear is:

slice.length = 0;

There is a reason const is also included.  Appender can take an *existing*
buffer and use it as the base for appending.  Since Appender!(const(T)[]) can
accept an immutable(T)[], you would have the same issue if you then called
clear on the data.

I'll note that clear is not enabled when the Appender is for const or immutable
arrays in the documentation.

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

Reply via email to