Skip to content

Conversation

9rnsr
Copy link
Contributor

@9rnsr 9rnsr commented Jul 10, 2012

@DmitryOlshansky
Copy link
Member

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

@alexrp
Copy link
Contributor

alexrp commented Jul 10, 2012

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

@DmitryOlshansky
Copy link
Member

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
Copy link
Contributor Author

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 9rnsr closed this Jul 10, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants