ref, safety, and warnings (was: ref and out required for function calls)
Timon Gehr
timon.gehr at gmx.ch
Sun Sep 23 12:50:16 PDT 2012
On 09/23/2012 07:37 PM, Andrej Mitrovic wrote:
> On 9/7/12, Kevin McTaggart <kevin.mctaggart at drdc-rddc.gc.ca> wrote:
>> snip
>
> There's one thing nobody mentioned yet, and that is that we're already
> using this syntax in the language -- in foreach loops:
>
> struct Foo { int x; }
> Foo[] arr = [{4}, {5}, {6}];
>
> foreach (idx, ref val; arr)
> {
> val.x = idx;
> }
> ...
That is not true. The only 'ref' in that code is a declaration site
annotation.
More information about the Digitalmars-d
mailing list