Fix ref-ness of and std.container.Array #678

wants to merge 3 commits into


None yet
3 participants

DmitryOlshansky commented Jul 10, 2012

About Array - I don't think so. It was meant to never leak an address of element.
It was called sealed container.


alexrp commented Jul 10, 2012

Can't take the address of an element? That's quite the useless array...


DmitryOlshansky commented Jul 10, 2012

You don't get it - it was supposed that e.g.
ar[x] = bleh;
would call opIndexAssign
then arr[].front = x;
should also do the correct forwarding thing. Apparently it didn't.


9rnsr commented Jul 10, 2012

From digitalmars.D newsgroup, @andralex says:

Hmm, that has a couple of issues.

First, map that modifies things in place is a bug more often than a feature given that the caller of map may use front() an arbitrary number of times. So I see little intentional and legitimate use for things like map!"a += 2"(range).

Second, the return by value from Array is intentional and has to do with sealing. Array is intended to never escape the addresses of its elements. That way, the collection is "sealed" in the sense there can never be uncontrolled pointers to its elements. This allows using efficient allocation strategies for the array without compromising its safety.

I can agree with his argument, so I close this pull request.

9rnsr closed this Jul 10, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment