Thread overview | |||||
---|---|---|---|---|---|
|
June 14, 2015 how come is this legal? 'void fun(int){ }' ? | ||||
---|---|---|---|---|
| ||||
Attachments:
| I understand this is legal for declaration wo definition (void fun(int);) but why allow this: void test(int){} ? |
June 14, 2015 Re: how come is this legal? 'void fun(int){ }' ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Timothee Cour | 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. |
June 14, 2015 Re: how come is this legal? 'void fun(int){ }' ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Timothee Cour | 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.
|
Copyright © 1999-2021 by the D Language Foundation