Re: [Libclc-developers] An alternative clc_list approach + an iterator.
Status: Planning
Brought to you by:
augestad
|
From: <bo...@me...> - 2003-03-25 19:13:34
|
Hallvard B Furuseth wrote: > Bjørn Augestad writes: > >>Attached is a file containing a list adt as well as an iterator adt. > > > clc_stl.h says: > > typedef struct clc_list_tag* clc_list; > typedef struct clc_iterator_tag* clc_iterator; > > I think typedefs to pointers like this is a bad idea. It makes > calls to functions like these: > > int clc_list_push_back(clc_list lst, void* data); > > look like they are sending a list argument which is only read by the > function, while the function is actually updating through the 'hidden' > pointer. > > I'd rather see > > typedef struct clc_list_tag clc_list; > typedef struct clc_iterator_tag clc_iterator; > > and > > int clc_list_push_back(clc_list *lst, void* data); Thanks for the feedback. The general concensus on c.l.c seems to be that it's OK to typedef the pointer if no struct members are available outside the implementation. That's my opinion as well. We can compromise by dropping the _tag suffix, typedef struct foo* foo; but then C++ gets *really* confused. ;-) How about the iterator concept? Do you think it can be applied to all the containers we want to add? Performance issues? Will it be too complex to use for beginners? Does the design easily create mem leaks? -- boa libclc home: http://libclc.sourceforge.net |