Re: [Libclc-developers] An alternative clc_list approach + an iterator.
Status: Planning
Brought to you by:
augestad
|
From: <bo...@me...> - 2003-03-22 19:16:04
|
Hallvard B Furuseth wrote:
> Iterator:
>
> clc_begin() and clc_end() looks like functions that begin and end
> something. Call them clc_atstart() and clc_atend().
Not a bad idea. ;-)
>
> Except, we may want more firsts and nexts and whatever, so maybe the
> iterator functions should start with clc_iter_, not just clc_.
clc_first(), clc_last() and friends solves a major issue I've had with
the whole clc_ prefix requirement, it makes the code *look ugly*.
Consider looping over a list:
for(s = clc_iter_first(i); !clc_iter_atend(i); s = clc_iter_next(i))
;
It's way too verbose and people will go blind trying to find out what
the line does. Even with the shortest possible variable names (s&i) and
a single indentation level of 4 spaces, a line will be 72 characters
wide! Now use 8 chars for indentation and add an indentation level or
two. :-(
I will have a very hard time living with code like that. This is much
more acceptable:
for(s = clc_first(i); !clc_atend(i); s = clc_next(i))
;
Remember that clc_* is *our* global name space and that we are allowed
to place functions there. We just have to be careful when choosing which
ones. If the iterator concept is accepted it will be used for most
container adt's and hence be widely used. Widely used stuff should be in
our global namespace, IMO.
(BTW, I would not have named clc_first()/clc_last() just first()/last()
if there wasn't a prefix requirement.)
Other opinions?
--
boa
|