Re: dip1000: why can't the addressee come into existence later?

2018-11-10 Thread Neia Neutuladh via Digitalmars-d-learn
On Sat, 10 Nov 2018 16:25:40 +, Stanislav Blinov wrote: > Yep, you just over-simplified the first case. It is too simple to clearly illustrate why the code is invalid, but not so simple that the compiler accepts that code. > Consider: > > int* p; > { > int i; > p = > } > *p =

Re: dip1000: why can't the addressee come into existence later?

2018-11-10 Thread Stanislav Blinov via Digitalmars-d-learn
On Saturday, 10 November 2018 at 06:56:29 UTC, Neia Neutuladh wrote: The following code doesn't work with @safe -dip1000: int* p; int i; p = i has a shorter lifetime than p, the compiler complains. But this code does: int i; int* p; p = The compiler does this even

Re: dip1000: why can't the addressee come into existence later?

2018-11-10 Thread Neia Neutuladh via Digitalmars-d-learn
On Sat, 10 Nov 2018 11:47:24 +, Nicholas Wilson wrote: > On Saturday, 10 November 2018 at 06:56:29 UTC, Neia Neutuladh wrote: >> Is this right? > > Are you sure you added @safe to the second example? > https://run.dlang.io/is/2RbOwK fails to compile. Maybe take another look at the post

Re: dip1000: why can't the addressee come into existence later?

2018-11-10 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 10 November 2018 at 06:56:29 UTC, Neia Neutuladh wrote: Is this right? Are you sure you added @safe to the second example? https://run.dlang.io/is/2RbOwK fails to compile.

dip1000: why can't the addressee come into existence later?

2018-11-09 Thread Neia Neutuladh via Digitalmars-d-learn
The following code doesn't work with @safe -dip1000: int* p; int i; p = i has a shorter lifetime than p, the compiler complains. But this code does: int i; int* p; p = In both cases, p can't point to i before i exists, and p ceases to exist when i ceases to exist.