On Wed, Feb 05, 2014 at 02:49:57PM +0100, Simon Ruderich wrote: > On Tue, Feb 04, 2014 at 08:17:05AM +0100, Thorsten Wißmann wrote: > > - I'm too lazy to continue writing void everywhere. > > - It looks totally ugly... > > - I don't see how ignoring that and writing ambigous fkt() causes any > > issues regarding security or stability. One will notice it if > > parameters to a function are ignored. > > But one might not immediately notice missing parameters to a > function, i.e. the caller forgot an argument. This won't ever happen. When calling a function like »void quit()«, you can't forget to pass a parameter. And if you change the signature to something else the compiler will complain if the caller forgets an argument. > > > // core functions > > > -int quit() { > > > +int quit(int argc, char* argv[]) { > > > g_aboutToQuit = true; > > > return 0; > > > } > > > > I really prefer the previous version, because in the other case there > > are parameters of that function which aren't used. Same for reload, > > true, false, etc. > > But a reader immediately knows that the function takes arguments > which are at the moment unused. I find that clearer. Well actually quit does not expect arguments, only after applying your patch. It does not care about arguments at all and needs none, but passing arguments to it does not cause trouble. That's what () is saying and what is happening here. It is OK to use quit as a command but it is also OK to call quit() directly without passing anything. > > Is there any advantage of writing (void), except that it is more > > "conform"? > > See above. It's not a big advantage, but it's clearer and can > prevent problems in the future. And to me the void doesn't look > too bad, but that's a matter of opinion of course. Well to me it looks bad, and it seems that language designers prefer an empty argument list "" to encode "does not need/expect/take any arguments" and not "void" (or something similar). It's just a hack in C. Cheers, Thorsten
Attachment:
pgpxvqlKkxDhu.pgp
Description: PGP signature