DIP1000: Scoped Pointers (Discussion)

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Fri Aug 12 03:32:19 PDT 2016


On 8/12/2016 2:42 AM, Robert burner Schadek wrote:
> Hm, that is really bad IMO. The shown use case is properly the most common use
> case. Is there no way to make it transitive so the lifetime of rcs[0] is the
> lifetime of rcs.

   rcs[0].a = 1337;
   assert(rcs[0].a == 1337);

It shouldn't be a big problem if the containers are shallow - the optimizer can 
remove the redundant computations.

> To be blunt, this is a real show-stopper for me.

Generally, it will require a more thorough use of encapsulation of containers 
and operations on them, if one is to use malloc/free or ref counting safely.


More information about the Digitalmars-d mailing list