Hacker News new | past | comments | ask | show | jobs | submit login

ANSI C could be cleaner than it is. I regularly lament that I must type

  int func(long_type_name a, long_type_name b, long_type_name c) { ...
when I really, really should be able to type

  int func(long_type_name a, b, c) { ...
It would be nice to get this back and it would take away some useless noise. Sadly, this is now seen as a feature and languages like D insist on the repeated type name.

I'm sure there are other places were ANSI C could be made cleaner, but perhaps at the cost of backwards compatibility.




> int func(long_type_name a, long_type_name b, long_type_name c) { ...

The K&R style variable declarations are still also part of ANSI C, so you could write:

    int func(a, b, c)
      long_type_name a, b, c;
    { ...


I don't now about the later versions of the standard but in C89, using the old style meant you did NOT get the type checking of the prototype style declarations. If there is no semantic difference these days, then yes, that would be a solution. I'm on the road and don't have the C11 standard handy, so I'll check later what the deal is.


Actually that's how Go does it,

   func(a, b, c long_type_name) int {...


> get this back

That never existed. Syntactically it could work; you would need semicolons in there:

  int func(long_type_name a, b, c; int d);
similar to struct/enum member declarations.

Speaking of which: don't have long type names in C programs, and simplify API's with structs rather than large numbers of parameters. :)


It exists with K&R parameters:

    void foo(a,b,c)
    long_type_name a,b,c;
    {
    ...
    }


Sorry, I didn't mean that literally, I meant getting equivalent functionality. I'd be fine with semicolons, Renderman Shading Language uses that syntax.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: