News for hackers. Stuff that matters.
Re:Porting the Go compiler from C to Go by rootbear on Friday April 25, 2014 @01:40PM (#7647926)
I use that style all the time. I like having the function name start in column 1, it can make searching easier.

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.
Re:Porting the Go compiler from C to Go by simias on Friday April 25, 2014 @02:01PM (#7648057)
That's a poor justification, there are plenty of tools to index and search C(++) code like ctags or cscope, and your example could use a vector or a struct, I have a hard time imagining when a function with such a prototype would be useful in real life.
Re:Porting the Go compiler from C to Go by clarry on Friday April 25, 2014 @02:59PM (#7648415)
Compound literals are not too pretty and not too well known. Plus, if you care about c89... So, do you wrap all your values in a struct because the prototype gets too long otherwise? What a chore.

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?

Re:Porting the Go compiler from C to Go by simias on Friday April 25, 2014 @03:36PM (#7648607)
No, I think everyone should use Emacs on FreeBSD, but that's not my point.

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.

Re:Porting the Go compiler from C to Go by coherentpony on Friday April 25, 2014 @01:48PM (#7647971)
structs are a good way to hide away all that state
Re:Porting the Go compiler from C to Go by rootbear on Friday April 25, 2014 @01:57PM (#7648041)
Agreed, but there are still times when I end up having several arguments of the same type, and I see no virtue in having to repeat the type for each formal parameter.
Re:Porting the Go compiler from C to Go by raverbashing on Friday April 25, 2014 @02:01PM (#7648060)
I don't see how having the type makes it easier to grep, grep finds the function name regardless

You can also search for something like "\w+\s(.?)\s*{"

Re:Porting the Go compiler from C to Go by coldtea on Friday April 25, 2014 @02:11PM (#7648128)
>I don't see how having the type makes it easier to grep, grep finds the function name regardless

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.

Re:Porting the Go compiler from C to Go by raverbashing on Friday April 25, 2014 @02:30PM (#7648246)
Yeah, ctags is a good choice

> "^foo" beats that

because it's so hard to use ctags...

Re:Porting the Go compiler from C to Go by clarry on Friday April 25, 2014 @03:03PM (#7648448)
So how do you use ctags with grep?
Re:Porting the Go compiler from C to Go by coldtea on Friday April 25, 2014 @04:11PM (#7648775)
It needs setup. I'd rather just grep.