Overloading static methods

2011-08-29 Thread Jacob Carlborg
I just got and idea, what about allowing to overload methods based on if they're static or not. This would allow the following code: class Foo { void bar () { writeln("bar"); } static void bar () { writeln("static bar"); } } Foo.bar; // would print "static bar" auto foo = new Foo; fo

Re: Overloading static methods

2011-08-29 Thread Daniel Murphy
"Jacob Carlborg" wrote in message news:j3fi1u$1uge$1...@digitalmars.com... >I just got and idea, what about allowing to overload methods based on if >they're static or not. >From my list of 'Andrei' bugs: http://d.puremagic.com/issues/show_bug.cgi?id=3345 It sounds like a good idea, but what a

Re: Overloading static methods

2011-08-29 Thread Jacob Carlborg
On 2011-08-29 16:10, Daniel Murphy wrote: "Jacob Carlborg" wrote in message news:j3fi1u$1uge$1...@digitalmars.com... I just got and idea, what about allowing to overload methods based on if they're static or not. From my list of 'Andrei' bugs: http://d.puremagic.com/issues/show_bug.cgi?id=33

Re: Overloading static methods

2011-08-29 Thread Steven Schveighoffer
On Mon, 29 Aug 2011 10:25:18 -0400, Jacob Carlborg wrote: On 2011-08-29 16:10, Daniel Murphy wrote: "Jacob Carlborg" wrote in message news:j3fi1u$1uge$1...@digitalmars.com... I just got and idea, what about allowing to overload methods based on if they're static or not. From my list of

Re: Overloading static methods

2011-08-29 Thread Daniel Murphy
"Steven Schveighoffer" wrote in message news:op.v0zckubyeav7ka@localhost.localdomain... > > My opinion is that static methods should *not* be callable from an > instance, you should need typeof(instance).staticMethod. The current > allowance is misleading. > > This should solve some of the iss

Re: Overloading static methods

2011-08-29 Thread Alex Rønne Petersen
On 29-08-2011 16:44, Steven Schveighoffer wrote: My opinion is that static methods should *not* be callable from an instance, you should need typeof(instance).staticMethod. The current allowance is misleading. +1. - Alex

Re: Overloading static methods

2011-08-29 Thread Jonathan M Davis
On Monday, August 29, 2011 07:44 Steven Schveighoffer wrote: > My opinion is that static methods should *not* be callable from an > instance, you should need typeof(instance).staticMethod. The current > allowance is misleading. Yeah. I don't know why it's allowed. I think that C++, Java, and C# al

Re: Overloading static methods

2011-08-29 Thread bearophile
Jonathan M Davis: > Yeah. I don't know why it's allowed. I think that C++, Java, and C# all allow > it too, but I've always thought that it was a bad idea in all of those > languages. > ... > but it strikes me as very lax to allow a static > method to be called with an instance. That's definite

Re: Overloading static methods

2011-08-29 Thread Alex Rønne Petersen
On 29-08-2011 19:47, Jonathan M Davis wrote: On Monday, August 29, 2011 07:44 Steven Schveighoffer wrote: My opinion is that static methods should *not* be callable from an instance, you should need typeof(instance).staticMethod. The current allowance is misleading. Yeah. I don't know why it's

Re: Overloading static methods

2011-08-29 Thread Jonathan M Davis
On Monday, August 29, 2011 12:53 Alex Rønne Petersen wrote: > On 29-08-2011 19:47, Jonathan M Davis wrote: > > On Monday, August 29, 2011 07:44 Steven Schveighoffer wrote: > >> My opinion is that static methods should *not* be callable from an > >> instance, you should need typeof(instance).staticM

Re: Overloading static methods

2011-08-30 Thread Steven Schveighoffer
On Mon, 29 Aug 2011 10:59:22 -0400, Daniel Murphy wrote: "Steven Schveighoffer" wrote in message news:op.v0zckubyeav7ka@localhost.localdomain... My opinion is that static methods should *not* be callable from an instance, you should need typeof(instance).staticMethod. The current allowanc

Re: Overloading static methods

2011-08-30 Thread Steven Schveighoffer
On Tue, 30 Aug 2011 07:53:15 -0400, Steven Schveighoffer wrote: On Mon, 29 Aug 2011 10:59:22 -0400, Daniel Murphy wrote: "Steven Schveighoffer" wrote in message news:op.v0zckubyeav7ka@localhost.localdomain... My opinion is that static methods should *not* be callable from an instance,

Re: Overloading static methods

2011-08-30 Thread Marco Leise
Am 29.08.2011, 22:24 Uhr, schrieb Jonathan M Davis : On Monday, August 29, 2011 12:53 Alex Rønne Petersen wrote: On 29-08-2011 19:47, Jonathan M Davis wrote: > On Monday, August 29, 2011 07:44 Steven Schveighoffer wrote: >> My opinion is that static methods should *not* be callable from an >> i

Re: Overloading static methods

2011-08-30 Thread Jacob Carlborg
On 2011-08-30 14:34, Steven Schveighoffer wrote: On Tue, 30 Aug 2011 07:53:15 -0400, Steven Schveighoffer wrote: On Mon, 29 Aug 2011 10:59:22 -0400, Daniel Murphy wrote: "Steven Schveighoffer" wrote in message news:op.v0zckubyeav7ka@localhost.localdomain... My opinion is that static meth

Re: Overloading static methods

2011-08-30 Thread Steven Schveighoffer
On Tue, 30 Aug 2011 10:19:27 -0400, Jacob Carlborg wrote: On 2011-08-30 14:34, Steven Schveighoffer wrote: On Tue, 30 Aug 2011 07:53:15 -0400, Steven Schveighoffer wrote: On Mon, 29 Aug 2011 10:59:22 -0400, Daniel Murphy wrote: "Steven Schveighoffer" wrote in message news:op.v0zckubyeav

Re: Overloading static methods

2011-08-30 Thread Jacob Carlborg
On 2011-08-30 16:28, Steven Schveighoffer wrote: It's different. 3345 is asking to allow overloading of static and instance methods with the same signature. The new bug is asking to *require* using the type when accessing static methods/fields. You might notice in the bug report that I mention t

Re: Overloading static methods

2011-08-30 Thread Andrei Alexandrescu
On 8/30/11 7:34 AM, Steven Schveighoffer wrote: On Tue, 30 Aug 2011 07:53:15 -0400, Steven Schveighoffer wrote: On Mon, 29 Aug 2011 10:59:22 -0400, Daniel Murphy wrote: "Steven Schveighoffer" wrote in message news:op.v0zckubyeav7ka@localhost.localdomain... My opinion is that static metho

Re: Overloading static methods

2011-08-30 Thread Andrei Alexandrescu
On 8/30/11 7:40 AM, Marco Leise wrote: Am 29.08.2011, 22:24 Uhr, schrieb Jonathan M Davis : On Monday, August 29, 2011 12:53 Alex Rønne Petersen wrote: On 29-08-2011 19:47, Jonathan M Davis wrote: > On Monday, August 29, 2011 07:44 Steven Schveighoffer wrote: >> My opinion is that static metho

Re: Overloading static methods

2011-08-30 Thread Steven Schveighoffer
On Tue, 30 Aug 2011 11:38:54 -0400, Andrei Alexandrescu wrote: On 8/30/11 7:34 AM, Steven Schveighoffer wrote: On Tue, 30 Aug 2011 07:53:15 -0400, Steven Schveighoffer wrote: On Mon, 29 Aug 2011 10:59:22 -0400, Daniel Murphy wrote: "Steven Schveighoffer" wrote in message news:op.v0zck

Re: Overloading static methods

2011-08-30 Thread Steven Schveighoffer
On Tue, 30 Aug 2011 11:58:20 -0400, Steven Schveighoffer wrote: On Tue, 30 Aug 2011 11:38:54 -0400, Andrei Alexandrescu wrote: We don't have as big a problem in D due to introspection. I fear, however, that we'll need to add static if (...) obj.method(); else typeof(obj).method(); I

Re: Overloading static methods

2011-08-30 Thread Steven Schveighoffer
On Tue, 30 Aug 2011 11:58:20 -0400, Steven Schveighoffer wrote: On Tue, 30 Aug 2011 11:38:54 -0400, Andrei Alexandrescu wrote: On 8/30/11 7:34 AM, Steven Schveighoffer wrote: We don't have as big a problem in D due to introspection. I fear, however, that we'll need to add static if (..

Re: Overloading static methods

2011-08-30 Thread Daniel Murphy
"Steven Schveighoffer" wrote in message > struct S2 > { >static void foo(); >alias foo this.foo; > } or alias typeof(this).foo foo;

Re: Overloading static methods

2011-09-24 Thread mta`chrono
Quote: Steven Schveighoffer > An example I gave in the bug report just now is File. Imagine you have > a File struct, and want to have an open method: > > struct File > { >static File open(string fname); > } > > However, now this is valid code: > > File f; // < here's the problem! >

Re: Overloading static methods

2011-09-26 Thread Steven Schveighoffer
On Sat, 24 Sep 2011 16:26:34 -0400, mta`chrono wrote: Quote: Steven Schveighoffer An example I gave in the bug report just now is File. Imagine you have a File struct, and want to have an open method: struct File { static File open(string fname); } However, now this is valid code: Fil