DMD 0.177 release

Kevin Bealer kevinbealer at gmail.com
Fri Dec 15 08:24:33 PST 2006


== Quote from Walter Bright (newshound at digitalmars.com)'s article
> Andrei Alexandrescu (See Website For Email) wrote:
> > I see this as D's #1 major problem as of today. I think the function
> > returning inout is better, but I foresee a bunch of issues with it. The
> > question whether lvalues are needed beyond function return values must
> > be satisfactorily answered.
>
> Ok, I think I understand the issue now. Also, it only applies to struct
> types, not class types. Class types are already reference types, so for
> them it's a non-issue.

In the case of opIndex(), I think it does affect classes too.  If I do this:

void Swap(inout T a, inout T b)
{
    T c=a; a=b; b=c;
}

class Vector { ... };
Vector X;

1. X[i].increment();
2. Swap(X[i], X[j]);

Both #1 and #2 would work for class or struct if X is a regular D array.  For
user-defined types, both of these fail if X is a struct.  For classes, #1 works
but I think #2 still fails.

Kevin



More information about the Digitalmars-d-announce mailing list