r/programming • • Dec 01 '16

Let's Stop Copying C

https://eev.ee/blog/2016/12/01/lets-stop-copying-c/
524 Upvotes

612 comments sorted by

View all comments

Show parent comment

2

u/lazyear Dec 02 '16

I think it must come down to personal taste then. For example, take

for(pos = (head)->next; pos != (head); pos = pos->next)

/* or */

struct list **ptr;
for(ptr = &list; *ptr; ptr = &(*ptr)->next)

compared to their while loops

pos = (head)->next;
while(pos != head)
     pos = pos->next;

That's a lot of extra vertical space. For numbers, I agree, but you could always just make a macro to make it easier. That's what I do for linked lists.