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

Pelle Månsson pelle.mansson at gmail.com
Wed Mar 10 07:39:28 PST 2010


On 03/10/2010 04:23 PM, bearophile wrote:
> 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

May we wish for a better error message in this case?

Anyway, I have always used += 1.



More information about the Digitalmars-d mailing list