This smells of very old code (as the header testifies)
This smells of very old code (as the header testifies)
> Portions Copyright © 2009 The Go Authors. All rights reserved
That's pretty recent.
And here's BSD style(9): http://www.freebsd.org/cgi/man.cgi?query=style&sektion=9
The function type should be on a line by itself preceding the function.I do wish that in C1x (for x > 1), they could find a way to let us declare multiple formal arguments of the same type without repeating the type:
float
my_graphics_hack(float x, y, z, r, g, b, u, v) { ...
instead of float my_graphics_hack(float x, float y, float z, float r, float g, float b, float u, float v) { ...
which gets really tedious and obfuscates that fact that they are all the same type, especially with the typename is more complex than just "float". When the new syntax was added to ANSI C, it wasn't possible to do multiple variables, for reasons I've forgotten but which I think had to do with forward type references. It would be awfully nice to find a fix for this.Preferring that function names start at the first column to make searching easier is a perfectly good justification.
You, on the other hand, seemingly would impose your tools (which have their shortcomings) and workflow on people with no justification at all.
Just because a tool exists, doesn't mean it's good (or better than what people are accustomed to) or that everyone must use it.
Do you think everyone should use Vim on Linux too?
Adding syntactic sugar to a language makes the language bigger and harder to completely understand, it makes it easier to misuse a feature (and C already has a lot of trickery with types, like when you declare a parameter as an array but it behaves like a pointer). I'm a strong believer that implicit is better than explicit and that while there are many ways to do the same thing some are better than other in practice. Of course, "in practice" can change from one project to the other, what matters in consistency. I applaud the choice of Go to standardize on a single coding style for instance.
For the particular example of the parent, while I write a lot of C code for work and for fun I have yet to encounter a situation where I saw a function taking 10 floats as arguments and thinking "yup, that's completely the right way to do that". If you have an example of such a code I'd me more that willing to reconsider my position, otherwise we're just talking about the best way to tame a unicorn.
You can also search for something like "\w+\s(.?)\s*{"
It's not about finding the function name in general, it's about finding where the function is actually declared -- not in the call sites.
>You can also search for something like "\w+\s(.?)\s{"*
Yeah, or use ctags. That's why they said "simpler".
"^foo" beats that.
> "^foo" beats that
because it's so hard to use ctags...
It is also a pretty common style in the open source world.
> It is also a pretty common style in the open source world.
Depends, one proeminent C project doesn't use that: the linux kernel
And I can do it without ctags. That's the point.
>Depends, one proeminent C project doesn't use that: the linux kernel
That doesn't make his statement "depends" at all. A single project not using that style does not contradict it being "pretty common".
int
main
(int argc, char **argv)
{
//body..
}
although most people think i'm weird for it.. int main(int argc, char **argv) {
//body..
}
I thought it was nice but not obviously advantageous, but over the years I've come around to thinking it makes code easier to follow. Even many bash shell scripting guides now recommend a similar form: for x in y; do
# body
done grep -n ^functionname *.c
and get the line that starts the definition