Just to resurrect an old old thread, since this same thread came
up at work just recently and now I wish to spark more discussion.
Jonathan Mcdougall wrote:
int f();
could not be more explicit.
David B. Held wrote:
Sure it could. Add "void".
Rolf Magnus wrote:
How does adding a pseudo parameter of type void make it more expicit
that you want no parameters?
The question that came up in my mind is that this "pseudo
parameter" isn't pseudo at all. It means, quite explicitly, that
the function takes no parameters.
While I understand that empty parentheses means "takes no
parameters," doesn't this beg the question (compatibility with
the first C aside) of why a function that takes no parameters
needs to have 'void' stated as its return type? I mean, if we're
trying to get rid of useless typing, certainly a function that
returns nothing (indeed, a function that doesn't even have an
explicit return statement) shouldn't need to specify that it
returns nothing- it could just get away with not stating that it
returns something.
To pull it all together, putting void in the parameters list is
only as silly (IMO) as putting void as the return type. Alas, I
still don't use void between the parens, but now see a lack of
symmetry in the way type specifiers are used.
Does my logic fail, besides contradicting The Almighty Standard?
-tom!