Implicit conversion of concatenation result to immutable

H. S. Teoh hsteoh at quickfur.ath.cx
Thu Apr 1 22:34:17 UTC 2021


On Thu, Apr 01, 2021 at 03:07:09PM -0700, Ali Çehreli via Digitalmars-d wrote:
> On 4/1/21 2:59 PM, H. S. Teoh wrote:
[...]
> > One may argue that appending in general will reallocate, and once
> > reallocated it will be unique, and there safe to implicitly convert
> > to immutable.  However, in general we cannot guarantee this
> 
> Yes, that's tricky for append because one of many slices does own the
> potential bytes after the array and will append elements in there.
> However, concatenation always makes a new array, right? I think the
> result can be char[] in that case.
[...]

If one of the arguments is an empty array, does concatenation allocate a
new array anyway? Or does it simply return the other argument? (I don't
know.)  If not, then we cannot make it implicitly convertible.


T

-- 
Genius may have its limitations, but stupidity is not thus handicapped. -- Elbert Hubbard


More information about the Digitalmars-d mailing list