DIP74 - where is at?

Johannes Pfau via Digitalmars-d digitalmars-d at puremagic.com
Mon Oct 12 03:31:42 PDT 2015


Am Mon, 12 Oct 2015 10:44:47 +0300
schrieb Andrei Alexandrescu <SeeWebsiteForEmail at erdani.org>:

> >> Probably git grep in phobos may be a good starting point.
> >>  
> >
> > I don't think grepping for return will have a good noise to signal
> > ratio.  
> 
> Sorry, I meant to git grep for "return ref".

AFAICS this returns only 6 results:

// false positive
std/functional.d:        static ref int func_ref() { return refvar; }

// test functions for return ref
std/functional.d:    ref int foo(return ref int a) { return a; }
std/traits.d:        void test(scope int, ref int, out int, lazy
  int, int, return ref int) { }
std/traits.d:        ref const(Inner[string]) retfunc( return ref Inner
var1 );



// Real examples

// I don't see the advantage here. Simple example, private API anyway,
// not using @safe
std/stdio.d:    private char[] takeFront(return ref char[4] buf)

// A good, but very simple example
std/utf.d:wchar[] toUTF16(return ref wchar[2] buf, dchar c) nothrow
  @nogc @safe



So AFAICS it's not used much and the use cases are rather simple
compared to RCSlice / RC!T / Unique and all these complex cases that
have been discussed related to ownership.


More information about the Digitalmars-d mailing list