scope in function argument

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Sep 23 10:39:42 PDT 2015


On 09/23/2015 10:11 AM, Adam D. Ruppe wrote:
 > On Wednesday, 23 September 2015 at 17:09:40 UTC, Freddy wrote:
 >> What does it mean when there is a scope in a function argument.
 >
 > That you are not supposed to let that reference escape the function
 > scope.

Just to complete with a related feature, here are also 'return' 
parameters, which make the compiler ensure that the returned reference 
lives longer than the 'ref' argument. Unfortunately, I can't see that 
feature here anymore:

   http://dlang.org/function.html#parameters

Has it been pulled back? It still works in 2.068. I had written about it:

 
http://ddili.org/ders/d.en/function_parameters.html#ix_function_parameters.return,%20parameter

Then there is the -dip25 compiler switch that forces the programmer to 
put 'return' on every returned 'ref' parameter, effectively enforcing 
that check:

   http://wiki.dlang.org/DIP25

Ali



More information about the Digitalmars-d-learn mailing list