array.length++ not an lvalue

Erik Lechak prochak at netzero.net
Wed Jun 18 06:12:19 PDT 2008


Hello all,

I just wanted to start by thanking you for the great responses to my previous questions.  I appreciate the knowledgeable and friendly nature of this newsgroup.

I ran into my first WTF moment with D.  I spent way too much time figuring out why 'array'.length++ was a compiler error (Error: x.length is not an lvalue).

This is a newsgroup entry describing the problem: 
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=39179

Is there a document detailing these "special exceptions" so that I don't have to blindly stumble upon them?  If not are there any more that should be documented so that I can add them to my Wiki (http://www.lechak.info/wiki/index.php?title=D_Programming_Language)?  

For what it's worth, I think 'array'.length++ and 'array'.length += 1 should be valid.  If that is not an option, it would be nice if the error message could be changed to something like "Error: x.length is a special property that prohibits the use of the increment (++) and add_and_assign (+=) operators".  

Thanks,
Erik Lechak




More information about the Digitalmars-d mailing list