Robert Bradshaw wrote: > On Mar 20, 2009, at 12:18 AM, Stefan Behnel wrote: > >> Greg Ewing wrote: >>> Robert Bradshaw wrote: >>> >>>> What about the behavior of >>>> >>>> for i from 0 <= i < 10: >>>> print i >>>> i += 5 >>> Undefined also. >> Saying "undefined" sounds a bit too simple here. Users will write >> this kind >> of code and intuitively expect it to work. > > I'd rather specify the behavior. How will people expect it to work? > Currently, the loop will exit early if i is a cdef int, and not if > it's a python object. Anyone have an opinion on this? (I'd be > inclined to specify the former behavior just to preserve backwards > compatibility.
When I see the above code, the only intuitive expectation I can come up with is to have it exit early. I think the syntax is sufficiently far from a for-in-range loop that no-one would expect i to be taken from an iterable here. It's much more intuitive to have a more or less direct mapping to a C loop that defines a start value, an boundary condition, and a step. So I'm +1 for officially allowing the above and making it exit early. Letting Cython basically ignore the "i += 5" would be a bug. Stefan _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
