Re: Call to arms, language bindings
- From: Philip Van Hoof <spam pvanhoof be>
- To: doclivingston gmail com
- Cc: tinymail-devel-list gnome org
- Subject: Re: Call to arms, language bindings
- Date: Fri, 04 Aug 2006 10:20:08 +0200
On Fri, 2006-08-04 at 14:56 +1000, James "Doc" Livingston wrote:
> On Tue, 2006-08-01 at 15:11 +0200, Philip Van Hoof wrote:
> > Improve the Python language binding
> > - implementing the sequence protocol
>
> After starting some work on this, I've noticed that a some of the
> operations that sequences have are hard to map onto the list/iterator
> API.
>
>
> * "length" maps directly
>
> * "get Nth item" work by creating an iterator, and using get_nth_item.
>
> * "copy" will map directly
>
> * "create iterator" should work fairly well (but I haven't done it yet)
>
> * "concatenate" should be possible by iterating over the second list and
> appending to the first (with special handling when they're the same
> list).
>
> * "set Nth item" is impossible as far as I can tell. TnyListIface has
> append and prepend, but nothing that can change an item.
You need to use the iterator for this. The list itself doesn't keep a
position state. That is what you use an iterator for.
It depends a little bit on how you read the iterator pattern. But in
Java and .NET (in .NET it's IEnumerator and IEnumeratable) it's
definitely not the list that keeps a position state.
-- If the list keeps the position state, it wouldn't be possible to have
multiple threads loop the same list simultaneously.
You can of course create one 'default' iterator per list instance. It's
not clean nor the right thing to do. But if that is what it takes to get
Python language bindings nice .. I will consider it
> * "delete Nth item" is impossible as far as I can tell. TnyListIface has
> "delete(data)", but doing "delete (get_nth (N))" won't work correctly if
> the item is in the list twice.
Maybe we can add this to the list interface? I wouldn't be against that.
Are you prepared to implement it for all list types? I think there's
something like four list implementations in current tinymail.
--
Philip Van Hoof, software developer at x-tend
home: me at pvanhoof dot be
gnome: pvanhoof at gnome dot org
work: vanhoof at x-tend dot be
http://www.pvanhoof.be - http://www.x-tend.be
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]