www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - how come is this legal? 'void fun(int){ }' ?

reply Timothee Cour via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> writes:
I understand this is legal for declaration wo definition (void fun(int);)
but why allow this:
void test(int){} ?
Jun 13 2015
next sibling parent "Adam D. Ruppe" <destructionator gmail.com> writes:
Sometimes you have empty functions and/or unused parameters just 
to fulfill some interface but you don't actually care about the 
arguments passed. No need to name them if you aren't going to use 
them.
Jun 13 2015
prev sibling next sibling parent "Maxim Fomin" <maxim-fomin outlook.com> writes:
On Sunday, 14 June 2015 at 01:20:39 UTC, Timothee Cour wrote:
 I understand this is legal for declaration wo definition (void 
 fun(int);)
 but why allow this:
 void test(int){} ?
Actually it is void test(int _param_0) { } You can test by compiling void test(int) { _param_0 = 0; } Nameless parameters are simulated by providing internal symbol as above.
Jun 13 2015
prev sibling parent ketmar <ketmar ketmar.no-ip.org> writes:
On Sun, 14 Jun 2015 05:11:17 +0000, Maxim Fomin wrote:

 On Sunday, 14 June 2015 at 01:20:39 UTC, Timothee Cour wrote:
 I understand this is legal for declaration wo definition (void
 fun(int);)
 but why allow this:
 void test(int){} ?
=20 Actually it is void test(int _param_0) { } You can test by compiling void test(int) { _param_0 =3D 0; } =20 Nameless parameters are simulated by providing internal symbol as above.
yet one shouldn't rely on generated names, they are undocumented on=20 purpose, and can change without a notice and deprecation cycle.=
Jun 13 2015