On 4/05/11 4:08 AM, Walter Bright wrote:
For example, should I pass an object around by ref or by value? In C++,
I've got to convert all my -> to . or vice versa, throughout the code.
With D, I just change the alias declaration.
How do you manage to change a pass-by-value to pass-by-reference by
changing an alias?
e.g.
struct Vec3(T) { ... }
T dot(Vec3!T a, Vec3!T b)
{
return a.x * b.x + a.y * b.y + a.z * b.z;
}
/* lots more functions that pass Vec3 by value */
How would you change Vec3!T to be passed by reference by changing an
alias param?
P.S.
In C++, you'd change
T dot(Vec3<T> a, Vec<T> b)
to
T dot(Vec3<T> const& a, Vec3<T> const& b)
No need to change . to ->