A question about move() and a rant about shared

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sat Jan 25 10:47:18 PST 2014


On 1/25/14 3:51 AM, Dmitry Olshansky wrote:
> 25-Jan-2014 02:13, Stanislav Blinov пишет:
>> On Friday, 24 January 2014 at 19:54:31 UTC, Dmitry Olshansky wrote:
>>> If I understand the current direction is to go with ref T and make
>>> some language
>>> level/compiler level changes to the escaping reference.
>>
>> Escaping... where? By "go with ref T" you mean return value of e.g.
>> front()?
>
> Say front returns a reference to a first element in an array.
> Say user stores &someArray.front as pointer somewhere, and the does
> someArray.insert([1,2,3,4,5]);
> In case array got resized the pointer is now dangling. Sealed containers
> were meant to prevent such class of errors entirely.

We plan to disallow taking address of a ref return from a function.

Andrei



More information about the Digitalmars-d mailing list