On Tue, 30 Dec 2014 21:28:32 -0800 Andrei Alexandrescu via Digitalmars-d <digitalmars-d@puremagic.com> wrote:
> The alternate hypothesis is "ref" is being misused. "ref" is for > propagating changes into the arguments. It should be rare that code does > not actually care for that. Unlike in C++, ref is seldom needed for > optimizing copies away. -- Andrei slightly derailing comment: the small annoyance of `ref` is that it hides the fact that i'm passing argument by reference. i still can't fully convince myself that i should use `ref` instead of explicit pointer, 'cause: void foo (ref int a); void bar (int a); // and the following calls looks all the same T_T int a; foo(a); bar(a); but: void foo (int* a); void bar (int a); // wow, we don't even need to look at the signatures to find // that `foo` wants a reference and that it therefore can // modify `a`! int a; foo(&a); bar(a); another "cosmetic issue" that bugs me alot. p.s. and with pointers it's easy to write something like this: auto parseNumber (string s, bool* error=null); yes, i know about exceptions... which blocks `@nogc`. not yummy.
signature.asc
Description: PGP signature