Bug in the spec or implementation?
Steven Schveighoffer
schveiguy at yahoo.com
Thu Aug 5 11:53:09 PDT 2010
On Thu, 05 Aug 2010 14:45:18 -0400, simendsjo <simen.endsjo at pandavre.com>
wrote:
> This is only tested on dmd 2.047 on win7.
>
> According to the spec at http://digitalmars.com/d/2.0/arrays.html:
> "Concatenation always creates a copy of its operands, even if one of the
> operands is a 0 length array"
>
> But this doesn't seem like the case:
>
> auto a = [0];
> auto oldPtr = a.ptr;
> assert(a.length == 1);
> assert(a.capacity == 3);
> a ~= 1;
> assert(a.ptr != oldPtr); // Fails - Still the same array
Concatenation is this:
a ~ 1
appending is this:
a ~= 1
Two separate operations, two separate semantics. It might not be easy to
determine that from the spec, but I believe the spec is clear.
-Steve
More information about the Digitalmars-d
mailing list