toki doki wrote: >> I did not submit an enhancement ticket for the "left-value assignment >> problems" yet, because I wanted to make some things clear first. To >> recap, there are actually two problems, I think: >> 1- If foo_iterator is an iterator, operator.dereference(foo_iterator) >> is not an l-value for cython. Therefore it is not possible to do the >> equivalent of " *foo_iterator=bar " in cython (except if foo_iterator >> is a pointer and not a general iterator) >> 2- functions returning references are not l-values for cython. >> Therefore, for example, it is not possible to use the ".at" method of >> std::vectors to assign a value. >> > > > I had not read the parallel thread between Stefan Behnel , Dag Sverre > Seljebotn and Sturla Molden. If I understand correctly, they advocate > that the return value of functions declared as returning a reference > should be automatically converted to a pointer (to the returned > referenced object). It makes sense. All things being equal, I would > have prefered a "set_lvalue" operator, but I am not the one doing the > implementation (nor do I understand the possible implementation > difficulties). > Which you should have posted to, instead of bringing the topic into this other thread. > Unfortunately, the problem is the same for functions returning > references: if a user write: foo=vect.at(4)+10, he might be expecting > to add 10 to the value at index 4 of vect, but in reality he will add > 10 to the address of this value. > Yes, the proposal is to make you have to write
foo = vect.at(4)[0] + 10 to get the equivalent of the C++ "foo = vect.at(4) + 10". I'll add another alternative to the other thread though. Dag Sverre _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
