Property rewriting; I feel it's important. Is there still time?

bearophile bearophileHUGS at lycos.com
Wed Mar 10 07:23:43 PST 2010


Andrei Alexandrescu:
> The idea is sensible and is already in effect for the ".length" property 
> of arrays.

I didn't know that. So I have tried this code:

void main() {
    int[] a;
    a.length++;
    a.length--;
}

The compiler shows the following errors, is this correct?
test1.d(3): Error: a.length is not an lvalue
test1.d(4): Error: a.length is not an lvalue


So I have tried this, and this compiles:

void main() {
    int[] a;
    ++a.length;
    --a.length;
}

Bye,
bearophile



More information about the Digitalmars-d mailing list