function pointer and default argument

2012-08-22 Thread Ellery Newcomer
hey. is this valid code? void func1(int i, double j = 1.0) { } void main() { auto fn = func1; func1(1); //dmd: ok fn(1); // dmd: not ok }

Re: function pointer and default argument

2012-08-22 Thread Ali Çehreli
On 08/22/2012 11:51 AM, Ellery Newcomer wrote: hey. is this valid code? void func1(int i, double j = 1.0) { } void main() { auto fn = func1; func1(1); //dmd: ok fn(1); // dmd: not ok } The type of the function pointer does not include the values of the default parameters. The type

Re: function pointer and default argument

2012-08-22 Thread Ellery Newcomer
On 08/22/2012 12:03 PM, Ali Çehreli wrote: On 08/22/2012 11:51 AM, Ellery Newcomer wrote: hey. is this valid code? void func1(int i, double j = 1.0) { } void main() { auto fn = func1; func1(1); //dmd: ok fn(1); // dmd: not ok } The type of the function pointer does not

Re: function pointer and default argument

2012-08-22 Thread Jonathan M Davis
On Wednesday, August 22, 2012 11:51:45 Ellery Newcomer wrote: hey. is this valid code? void func1(int i, double j = 1.0) { } void main() { auto fn = func1; func1(1); //dmd: ok fn(1); // dmd: not ok } Default arguments are not part of the type. This behavior is very much on

Re: function pointer and default argument

2012-08-22 Thread Ali Çehreli
On 08/22/2012 12:15 PM, Ellery Newcomer wrote: On 08/22/2012 12:03 PM, Ali Çehreli wrote: On 08/22/2012 11:51 AM, Ellery Newcomer wrote: hey. is this valid code? void func1(int i, double j = 1.0) { } void main() { auto fn = func1; func1(1); //dmd: ok fn(1); // dmd: not ok } The