On Sun, Nov 15, 2009 at 22:16, David Brownell <davi...@pacbell.net> wrote: > [ Offtopic thread #1: "struct typedefs considered harmful" ] > >> struct foo >> >> and >> >> foo_t >> >> are both universally understood. > > I can't know what a "foo_t" is without looking it up, > so it's not "universal" in any meaningful sense. > > >> "struct foo" however clutters the >> code, especially in long function parameter lists, and distracts from >> the underlying algorithms/parameters. > > When I see "foo_t" param I can't know how to use it. > > When I see "struct foo" I know it's a struct passed by > value; access as NAME.member, and it's safe to mangle.
You of course don't know that member until you looked up the definition of struct foo_t. So you are back at where you have to look the type up to do anything meaningful with it. > When I see "struct foo *" I now it's a struct passed by > pointer; access as NAME->member, and unsafe to mangle > (except according to what callers expect). See comment above. > When I see "int" I know it's passed by value, and is > safe to mangle; no substructure access syntax. Well, I have never encountered that state of confusion that you describe with any actual code. So I can't follow you here. >> What you call "standard" is just other people's programming preferences. > > It's standard in the sense that you know what it means > just by looking at those few lines ... no need to look > anywhere else to know the basics. New-to-the-project > programmers have less to learn, which seems healthy. I guess we have very different approaches to looking at new software. Since the structures (classes) are the skeleton around which openocd is structured it seems a bit far-fetched to me that you could go through the code without looking at the structs. > If you call wanting to *avoid* any "look *everything* up > in some type catalog" steps a programming preference ... > I can hardly stop you. Here is an example: void foo(struct bar_t * b); What can you do with this function without looking up bar_t or seeing its function body ? Michael _______________________________________________ Openocd-development mailing list Openocd-development@lists.berlios.de https://lists.berlios.de/mailman/listinfo/openocd-development