Re: What is 'scope' in function parameter?

2017-12-27 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, December 25, 2017 12:11:58 Mike Franklin via Digitalmars-d-learn wrote: > But we need people to use -dip25 and -dip1000 and provide > feedback, submit bug reports, etc.. so we can move the > implementation forward. Anyone who wishes to play around with those flags is free to do so,

Re: What is 'scope' in function parameter?

2017-12-26 Thread Sobaya via Digitalmars-d-learn
On Tuesday, 26 December 2017 at 00:17:33 UTC, Mike Franklin wrote: After a few hours trying to figure out why the compiler didn't catch this, I finally figured it out. You have to add `@safe`. import std.stdio; int[] x; void func(scope int[] a) @safe { x = a; } void main() @safe {

Re: What is 'scope' in function parameter?

2017-12-25 Thread Mike Franklin via Digitalmars-d-learn
On Monday, 25 December 2017 at 10:42:55 UTC, Sobaya wrote: ``` import std.stdio; int[] x; void func(scope int[] a) { x = a; } void main() { func([0,1,2]); writeln(x); } ``` This code was successfully compiled and printed '[0, 1, 2]'. But according to

Re: What is 'scope' in function parameter?

2017-12-25 Thread Mike Franklin via Digitalmars-d-learn
On Monday, 25 December 2017 at 11:09:25 UTC, Jonathan M Davis wrote: ``` import std.stdio; int[] x; void func(scope int[] a) { x = a; } void main() { func([0,1,2]); writeln(x); } ``` This code was successfully compiled and printed '[0, 1, 2]'. But according to

Re: What is 'scope' in function parameter?

2017-12-25 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, December 25, 2017 10:42:55 Sobaya via Digitalmars-d-learn wrote: > What means 'scope' in function parameter? > > I made a test code. > > ``` > import std.stdio; > > int[] x; > > void func(scope int[] a) { > x = a; > } > > void main(

What is 'scope' in function parameter?

2017-12-25 Thread Sobaya via Digitalmars-d-learn
What means 'scope' in function parameter? I made a test code. ``` import std.stdio; int[] x; void func(scope int[] a) { x = a; } void main() { func([0,1,2]); writeln(x); } ``` This code was successfully compiled and printed '[0, 1, 2]'. But according to https://dlang.org/spec