Re: static vs non-static

2013-01-15 Thread Era Scarecrow
On Sunday, 13 January 2013 at 16:39:22 UTC, bearophile wrote: Maxim Fomin: dmd allows to call static functions on instance. I think that's a D design mistake (and I think Jonathan Davis agrees with me), but Walter prefers the current behavour. I'll have to disagree and it should remain

Re: static vs non-static

2013-01-15 Thread Maxim Fomin
On Tuesday, 15 January 2013 at 22:03:24 UTC, Era Scarecrow wrote: On Sunday, 13 January 2013 at 16:39:22 UTC, bearophile wrote: Maxim Fomin: dmd allows to call static functions on instance. I think that's a D design mistake (and I think Jonathan Davis agrees with me), but Walter prefers

static vs non-static

2013-01-13 Thread Zhenya
Hi! Sorry,if it already was discussed,but import std.stdio; struct Foo { static void bar() { writeln(static); } void bar() { writeln(non-static); } } int main() { Foo gun; gun.bar();//fails here } Is it

Re: static vs non-static

2013-01-13 Thread Maxim Fomin
On Sunday, 13 January 2013 at 15:58:56 UTC, Zhenya wrote: Hi! Sorry,if it already was discussed,but import std.stdio; struct Foo { static void bar() { writeln(static); } void bar() { writeln(non-static); } } int

Re: static vs non-static

2013-01-13 Thread bearophile
Maxim Fomin: dmd allows to call static functions on instance. I think that's a D design mistake (and I think Jonathan Davis agrees with me), but Walter prefers the current behavour. Bye, bearophile

Re: static vs non-static

2013-01-13 Thread Zhenya
On Sunday, 13 January 2013 at 16:39:22 UTC, bearophile wrote: Maxim Fomin: dmd allows to call static functions on instance. I think that's a D design mistake (and I think Jonathan Davis agrees with me), but Walter prefers the current behavour. Bye, bearophile Maybe you could suggest

Re: static vs non-static

2013-01-13 Thread Andrey
Definitely this is a bad design. Even in PHP you can't call static functions from class instance. :-) Having two functions with the same name and argument list within one class is a bad idea too.

Re: static vs non-static

2013-01-13 Thread Zhenya
On Sunday, 13 January 2013 at 17:17:54 UTC, Maxim Fomin wrote: On Sunday, 13 January 2013 at 16:23:27 UTC, Zhenya wrote: On Sunday, 13 January 2013 at 16:18:36 UTC, Maxim Fomin wrote: Yes, it is a problem - dmd allows to call static functions on instance. When both match, it issues ambiguity

Re: static vs non-static

2013-01-13 Thread Andrey
Don't know if this will be useful in any manner, but it came this silly way: class MyClass { struct _static { static void myfun() { writeln(static myfun); } } void myfun() { writeln(myfun);

Re: static vs non-static

2013-01-13 Thread Zhenya
On Sunday, 13 January 2013 at 17:59:28 UTC, Andrey wrote: Don't know if this will be useful in any manner, but it came this silly way: class MyClass { struct _static { static void myfun() { writeln(static myfun); } }

Re: static vs non-static

2013-01-13 Thread Zhenya
On Sunday, 13 January 2013 at 18:16:40 UTC, Zhenya wrote: On Sunday, 13 January 2013 at 17:59:28 UTC, Andrey wrote: Don't know if this will be useful in any manner, but it came this silly way: class MyClass { struct _static { static void myfun() {

Re: static vs non-static

2013-01-13 Thread Jacob Carlborg
On 2013-01-13 16:58, Zhenya wrote: Hi! Sorry,if it already was discussed,but import std.stdio; struct Foo { static void bar() { writeln(static); } void bar() { writeln(non-static); } } int main() { Foo gun; gun.bar();//fails here } Is it all right,that compiler dosn't prefer non-static