Structs by ref in D2

Daniel Keep daniel.keep.lists at gmail.com
Fri Aug 21 07:42:08 PDT 2009



Lutger wrote:
> By const ref seems reasonable to allow, but by ref is bug prone. Why is it 
> handy? 

struct Vector4
{
    float[4] xyzw;
    Vector opAdd(ref Vector rhs);
}

Vector code can be made much faster using ref arguments, but if you use
ref arguments, you can't have anything more complex than a single binary
expression.

D's stance at the moment seems to be: "speed, convenience: pick one"

/sadface


More information about the Digitalmars-d-learn mailing list