in / out for C++ programmers

Ali Çehreli acehreli at yahoo.com
Sat Mar 24 00:17:01 PDT 2012


On 03/23/2012 11:50 PM, Jonathan M Davis wrote:
 > I believe that scope is used primarily
 > with delegates however (particularly, since you often _want_ to be 
able to
 > return a slice of an array passed to a function). It guarantees that 
the the
 > delegate's context won't escape the function and can make it so that the
 > delegate's context doesn't have to be allocated on the heap, which 
improves
 > efficiency.

Ok, I read it more carefully. What you are saying is that 'scope' may 
make more sense when applied to a parameter of a delegate.

There are two parties involved:

- User of the delegate as in dlg(someArg);

- Creater of the delegate as in 'return a => a + localVariable;'

Is that a requirement of the delegate or the user of the delegate in 
that case? Or, is that a guarantee of the delegate or the caller of the 
delegate?

Yes, I am completely lost on the semantics of 'scope' parameters. :)

Ali



More information about the Digitalmars-d-learn mailing list