April 22, 2003
Am I correct in saying that the problem is that we can't know if postfix++ happens before or after the assignment, which depends on the ++ executing before the assignment, or it'll store into invalid memory?

// a [a.length ++] = 4;  // bad

This seems to be a sort of reverse argument for defining when postfix ++ happens better.  Instead of just "before the next sequence point" define it to be "before any expression which uses the result of the x++ is evaluated". At least for arguments which aren't simple integers, such as a.length, where incrementing has side effects.

C is so imprecise.  D doesn't have to be.  The result:  more portable code for everybody.

Sean

"Burton Radons" <loth@users.sourceforge.net> wrote in message news:b82ja0$hdf$1@digitaldaemon.com...
> Vathix wrote:
>
> > None of this is necessary but might be good for convenience:
> >
> > 1)
> > Why can't I use ++, += etc on a dynamic array's .length?  Those
operators
> > are for typing less, so why can't I be lazy with this too?  :+)
>
> This didn't get described correctly.  It's because of "a [a.length ++] = 4", which is an undefined expression.  Like the ban on "if (a = b)", I think it's addressed at the wrong level; it should identify this easy-to-write and incorrect code in the semantic level, rather than having a catch-all that grabs many benign uses of .length.


1 2
Next ›   Last »