On Thu, 2008-01-03 at 15:38 +0100, Lars Uffmann wrote:
Erik Wikstr=C3=B6m wrote:
foo() clearly indicates that there =20
are no arguments, foo(void) at a glance looks like it takes an argumen=
t
and you have to see that the type is void before you understand that
there are no arguments.
=20
@Erik: point taken, at this point I was ready to accept this and apply=20
it to my own code, but then...
=20
jkherciueh@gmx.net wrote:
On the other hand, I find it very nice that=20
foo( void )
does not look like the function call and clearly indicates that I am lo=
oking
at a declaration. For that reason, it also increases grep-ability of th=
e
code.
=20
=20
Kai-Uwe also has a very good point there. Especially on the grep-ability =
:)
=20
I'm thinking especially about forward declarations that will look=20
exactly like a function call. Have to chew on this for a bit - unless=20
someone comes up with better arguments ;) Thanks to both of you!
I suppose something like this would be nasty:
#define UI_DEFAULT_MYOBJ_ARGS 0, "foo"
struct myclass {
myclass(int, const std::string&);
myclass();
};
void ui_default_path()
{
myclass myobj(UI_DEFAULT_MYOBJ_ARGS);
// .. do stuff ..
}
and then somebody redefines =EF=BB=BFUI_DEFAULT_MYOBJ_ARGS
#define =EF=BB=BFUI_DEFAULT_MYOBJ_ARGS
confusing compile error ensues.
The next version of C++ will probably have curly braces for
initialisation which can be used to prevent this problem occuring.
--=20
Tristan Wibberley
Any opinion expressed is mine (or else I'm playing devils advocate for
the sake of a good argument). My employer had nothing to do with this
communication.
.