[Xcb] Iter

Jamey Sharp jamey at minilop.net
Tue Dec 20 15:10:43 PST 2005

On Sat, Dec 17, 2005 at 07:56:38PM -0500, Jeremy Kolb wrote:
> Jamey Sharp wrote:
> > Yes, maybe that is a bit confusing. But when they're available arrays
> > are so convenient under many circumstances, and I expect if we take them
> > away people are going to start pretending that the pointer inside the
> > iterator is actually an array, and then they're going to do that for
> > types where that doesn't work, and that'll be even more confusing. At
> > least this way you get a compile-time error if you try to use an access
> > method that isn't available.
> The problem with having some of these "iterator only" is that you may
> need to access data already gone over.

Is it really common to need constant-time random-access to list
elements? I'd be interested in seeing examples.

> I think we should bite the bullet and just provide array access.  I
> don't think it would be too difficult to copy data around (though I
> don't know much about the internal design of XCB so I can't really
> comment on that).  The namespace is hard enough to read as it is ;)

I'm not entirely opposed to the idea, but it has to be clear to the
caller that they're incurring the expense of a copy, and that they're
going to have to free the returned array. So array copy functions should
be named differently from the non-copying array functions. But then, of
course, users will still have to know whether they can use the fast,
allocation-free array accessor or whether they have to use the slow
mallocing one.

That said, I'd love to see a patch. :-)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.freedesktop.org/archives/xcb/attachments/20051220/725ae8c1/attachment.pgp

More information about the Xcb mailing list