On 4/11/2015 2:18 AM, "Marc =?UTF-8?B?U2Now7x0eiI=?= <schue...@gmx.net>" wrote:
On Friday, 10 April 2015 at 21:26:14 UTC, Walter Bright wrote:
On 4/10/2015 11:28 AM, "Marc =?UTF-8?B?U2Now7x0eiI=?= <schue...@gmx.net>" wrote:
Example:

void foo() @safe {
    RCArray!int arr = [0,1,2];
    {
        int* p = &arr[0];  // legal under new scope rules

This would be a bad design of an RCO. RCO's must be constructed to not allow
pointers to the payload other than by ref.

There is no reason for this restriction.

The reason is to prevent unsafe access of the payload.


But if this is your opinion, why did
you agree to "implement 'scope' and 'return' for arrays, classes, and pointers"?

http://forum.dlang.org/post/mfhkbm$2vbk$1...@digitalmars.com

It makes no sense to implement that, but not allow it to be used safely.

In your example posted upthread, it wasn't safe. Perhaps scoped pointers can't be made safe for RCOs, or perhaps the proposal needs more thinking. I don't know at the moment.

Reply via email to