anything like C++ references?

Moshe Zadka m at moshez.org
Wed Jul 16 13:51:20 EDT 2003


On Wed, 16 Jul 2003, Michael Chermside <mcherm at mcherm.com> wrote:

>     stuff[i] = newComplexObject(i++, "name", "fred")

I'm not entirely sure that C code is not undefined. I think it
is, but it could be that I'm mistaken and that "=" is a "sequence point".
It's a variant on the old

a[i]=i++ 

thing. The problem here is that it's not certain what happens first --
the a[i] (evalating to an lvalue) or i++. Since an optimizing compiler
might even put both instruction in a single pipeline, it could be that
i is neither the old value or the new value at all by the time a[i]
is on the stack. In fact, the C standard, if I'm right, gives the C
compiler carte blanche to do whatever it feels like doing.

In Python, you'd've been forced to write

i+=1
stuff[i] = nCO(i)

or

stuff[i] = nCO(i)
i+=1

or

j,i=i,i+1
stuff[i] = nCO(j)

depending on what you meant.
-- 
Moshe Zadka -- http://moshez.org/
Buffy: I don't like you hanging out with someone that... short.
Riley: Yeah, a lot of young people nowadays are experimenting with shortness.
Agile Programming Language -- http://www.python.org/





More information about the Python-list mailing list