Stefan Behnel wrote:
> 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...)

The solution you scetch sounds to me like adding support for the Python 
"os" module to Cython :-) And we don't do that, we use getattr/etc. 
etc., because then we support all the other modules and usecases as well.

Ahh; the missing piece: Iterators are nothing special in C++. There's 
absolutely *no* concept of an iterator in the language. It's just a set 
of conventions.

So that's why I propose focusing on just getting the very basic 
interfacing of the languages done, and get it all supported instead of 
just STL.

When it comes to ++/--, basic fact is that it can be used for whatever 
purpose in C++. We are, after all, talking about the language which 
overloads "<<" for being "output to stream" -- again, with *no* explicit 
support for streams in the language; just by the usual operator overloading.

-- 
Dag Sverre
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to