Re:Applying the Linus Torvalds “Good Taste” Coding Requirement
by akkartik on Wednesday October 26, 2016 @01:46PM
(#12798686)
I have nothing against double pointers: https://news.ycombinator.com/item?id=12798604 (please don't consider the flamey bits there to be directed at you).
That last bit, though, I wouldn't recommend it as a slogan :) How about something like "adapt to the situation for life"?
Don't be afraid of double pointers, although they may seem overly clever at first glance, they can be really helpful for situations like this. Linus's code is considerably shorter, and not particularly difficult to debug or to understand, assuming you understand double pointers.
Another case where double pointers can be really useful is in the interface for linked lists. I.e.
Defining the interface that way allows properly removing the last entry from the list. Workarounds like making a list struct and passing a pointer to that are just double pointers in disguise. Returning the new head is error prone, since you can easily forget to reassign it.Double pointers for life!