Dag Sverre Seljebotn wrote: > Stefan Behnel wrote: >> Dag Sverre Seljebotn wrote: >>> Robert Bradshaw wrote: >>>> I am also for supporting only a subset of what >>>> is possible--if one really needs crazy stuff like differently >>>> implemented prefix/postfix decrements and -> vs (*). one can code in C >>>> ++ or use clever macros. (Would we need to expose ++, a.k.a >>>> "__next__" for STL iterators?) >>> Yes, you need ++/-- for std::list<T>::iterator, which doesn't accept any >>> form of += >> Am I missing something here? Why isn't the for-loop syntax enough for C++ >> iterators? > > Who's saying that you always want to iterate through all elements from > beginning to end in one go?
Well, it's the most common case, at least. For the rest, there's reversed() and islice(), which we could define (and optimise) on C++ iterators. Maybe just our own version (as we might have to fix up the semantics), such as "cython.cppitertools.islice()". Although overriding the standard function might make life a lot easier for users. I (basically) never used C++, so I may not be aware of all implications, but I would prefer not reinventing stuff that Python already has, just because we are dealing with a different 'backend'. The fewer things we need to add to the language, the more seamlessly the C++ integration will become. > But yes, one could use the for-loop syntax for that specific case. > > (However myself I'm in favor of even getting the most basic things > working before adding support in higher-level constructs.) But isn't the for-in-loop the most basic thing that you could get to work for iterators? (at least from a Python POV...) Stefan _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
