Opened 11 years ago

Closed 11 years ago

#529 closed enhancement (fixed)

Simplify list_foreach iteration

Reported by: Jiri Svoboda Owned by:
Priority: minor Milestone:
Component: helenos/unspecified Version: mainline
Keywords: Cc:
Blocker for: Depends on:
See also:

Description

Currently list_foreach presents a link_t * as an iterator. This leads to almost any list_foreach loop over a list of foo_t to look like this:

list_foreach(list, link) {
    foo_t *foo = list_get_instance(link, foo_t, link_field);
    ... use foo ...
}

therefore it would make sense to simplify the syntax to either:

list_foreach(list, foo_t, foo, link_field) {
   ... use foo ...
}

or

list_foreach(list, link_field, foo_t, foo) {
   ... use foo ...
}

the only downside being, one has to remember the correct order of four arguments.

Please let me know your comments on this proposal.

Change History (1)

comment:1 by Jiri Svoboda, 11 years ago

Resolution: fixed
Status: newclosed

Implemented in mainline,1946 (the latter variant).

Note: See TracTickets for help on using tickets.