On 12/5/2014 7:27 AM, Steven Schveighoffer wrote:
Can someone who knows what this new feature is supposed to do give some Ali
Çehreli-like description on the feature? Basically, let's strip out the *proof*
in the DIP (the how it works and why we have it), and focus on how it is to be
used.

I still am having a hard time wrapping my head around the benefits and when to
use scope, scope ref, why I would use it. I'm worried that we are adding all
this complication and it will confuse the shit out of users, to the point where
they won't use it.

The tl;dr version is when a declaration is tagged with 'scope', the contents of that variable will not escape the lifetime of that declaration.

It means that this code will be safe:

   void foo(scope int* p);

   p = malloc(n);
   foo(p);
   free(p);

The rest is all the nuts and bolts of making that work.

Reply via email to