[Issue 15982] std.array.array treats dynamic arrays as input ranges and allocates new memory

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Jun 27 09:28:22 PDT 2017


https://issues.dlang.org/show_bug.cgi?id=15982

Vladimir Panteleev <dlang-bugzilla at thecybershadow.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |dlang-bugzilla at thecybershad
                   |                            |ow.net
         Resolution|---                         |WONTFIX

--- Comment #11 from Vladimir Panteleev <dlang-bugzilla at thecybershadow.net> ---
As discussed above, std.array.array currently guarantees that the data it
returns is unique. This guarantee in turn allows some assumptions, such as that
writing to the result will not have side effects, that it is safe to pass to
other parts of the program, or even delete it. I suppose that if the array were
to point to immutable elements, avoiding reallocation might be worth
considering; though, currently, even .idup will duplicate an immutable array.

As it is, this issue is missing a use case, and it will probably need to be a
compelling one to warrant changing the function's contract and risking code
breakage. Other than that... well, if you don't want your array reallocated,
then just don't call array()?

Please reopen if you have a good argument why this should be changed despite
the above.

--


More information about the Digitalmars-d-bugs mailing list