Re: [C++-SIG] How to use CXX...
"Paul F. Dubois" <dubois1@llnl.gov> writes:
It is clear that a Python sequence type is a random access container. The class Sequence in CXX is too. If you want to wrap a class that is not a random access container, then it isn't a Sequence. You can invent a new class for it that is a child of Object in the same way that Sequence is, with whatever access rules you think are appropriate, but if your can't do x[i] in reasonable time it is simply deceptive to have such an operator.
The syntax I'm looking to enable is just iteration: for item in seq print item
From looking at the CXX Sequence implementation, it seems that Python when Python executes the above code, it creates an internal index and successively calls sequence_item(int), incrementing the index as it goes. It would be like an iterator implemented in terms of an index and an accessor function. This is different from COM's approach: internal use of an iterator object supporting Next()-like functions.
Is it possible to expose the iteration capability without implementing sequence_item(int)? Your quote above suggests that it's possible, but I can't see how. -- Steven E. Harris Primus Knowledge Solutions, Inc. http://www.primus.com
participants (1)
-
Steve Harris