DIP77 - Fix unsafe RC pass by 'ref'
via Digitalmars-d
digitalmars-d at puremagic.com
Sat Apr 11 02:18:02 PDT 2015
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=?=
> <schuetzm at 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. 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.
More information about the Digitalmars-d
mailing list