digitalmars.D.learn - Can't compile the code
- Temtaime (10/10) Apr 28 2013 int main() {
- =?UTF-8?B?QWxpIMOHZWhyZWxp?= (4/14) Apr 28 2013 It is probably one of the known issues with default delegate parameters:
- bearophile (4/5) Apr 28 2013 I don't understand this syntax.
- =?UTF-8?B?QWxpIMOHZWhyZWxp?= (4/9) Apr 28 2013 The name of the parameter is omitted. Could have named it as 'p':
- bearophile (6/9) Apr 28 2013 OK. But is it syntactically allowed in D to omit the variable
- Maxim Fomin (14/24) Apr 28 2013 That's because currently no variable name means _param_XXX,
int main() {
auto f = (bool = false) {};
f();
return 0;
}
I can't compile this code on
DMD32 D Compiler v2.062
On windows. It says to me:
Error: expected 1 function arguments, not 0
On linux it seems to work(http://ideone.com/fsKYWR).
Apr 28 2013
On 04/28/2013 01:53 AM, Temtaime wrote:
int main() {
auto f = (bool = false) {};
f();
return 0;
}
I can't compile this code on
DMD32 D Compiler v2.062
On windows. It says to me:
Error: expected 1 function arguments, not 0
On linux it seems to work(http://ideone.com/fsKYWR).
It is probably one of the known issues with default delegate parameters:
http://d.puremagic.com/issues/show_bug.cgi?id=3866
Ali
Apr 28 2013
Temtaime:
auto f = (bool = false) {};
I don't understand this syntax.
Bye,
bearophile
Apr 28 2013
On 04/28/2013 09:14 AM, bearophile wrote:Temtaime:The name of the parameter is omitted. Could have named it as 'p': auto f = (bool p = false) {}; Aliauto f = (bool = false) {};I don't understand this syntax. Bye, bearophile
Apr 28 2013
Ali Çehreli:
The name of the parameter is omitted. Could have named it as
'p':
auto f = (bool p = false) {};
OK. But is it syntactically allowed in D to omit the variable
name when there is a default argument? I have never seen it
before...
Bye,
bearophile
Apr 28 2013
On Sunday, 28 April 2013 at 18:40:20 UTC, bearophile wrote:Ali Çehreli:That's because currently no variable name means _param_XXX, moreover it can be accessed. int dummy; void foo(ref int = dummy) { _param_0 = -1; } void main() { int x; foo(x); assert(x is -1); }The name of the parameter is omitted. Could have named it as 'p': auto f = (bool p = false) {};OK. But is it syntactically allowed in D to omit the variable name when there is a default argument? I have never seen it before... Bye, bearophile
Apr 28 2013









=?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> 