On Monday, June 24, 2013 11:51:52 Steven Schveighoffer wrote:
> My suggestion to fix this has always been: only allow static calls on
> instance variables via opt-in. e.g.:
>
> class InfiniteRange
> {
> static bool empty() { return false; }
> alias InfiniteRange.empty this.empty; // just an exampl
On Monday, June 24, 2013 19:13:45 Jesse Phillips wrote:
> On Sunday, 23 June 2013 at 10:09:39 UTC, Jonathan M Davis wrote:
> >> Also I don't know why I should call static methods from an
> >> instance. What's the purpose?
> >
> > It's stupid and pointless as far as I can tell, but I believe
> > th
On Sunday, 23 June 2013 at 10:09:39 UTC, Jonathan M Davis wrote:
Also I don't know why I should call static methods from an
instance. What's the purpose?
It's stupid and pointless as far as I can tell, but I believe
that C++, Java,
C#, and D all do it, so as stupid as it is, it's a common
stu
On Sun, 23 Jun 2013 06:09:19 -0400, Jonathan M Davis
wrote:
On Sunday, June 23, 2013 12:02:42 Namespace wrote:
Also I don't know why I should call static methods from an
instance. What's the purpose?
It's stupid and pointless as far as I can tell, but I believe that C++,
Java,
C#, and
On Sunday, June 23, 2013 13:35:55 monarch_dodra wrote:
> On Sunday, 23 June 2013 at 10:59:06 UTC, Jonathan M Davis wrote:
> > On Sunday, June 23, 2013 12:48:15 monarch_dodra wrote:
> >> C++ doesn't allow it. I don't know about the rest.
> >
> > Yes it does.
> >
> > - Jonathan M Davis
>
> Oh. Wow
On 2013-06-23 12:04, Jonathan M Davis wrote:
I would have thought that that was obvious, and I fail to see why that would
be a problem. The only risk I see in allowing static and non-static functions
to be overloaded, is that if you have static function being called with an
instance, and you add
On Sunday, 23 June 2013 at 10:59:06 UTC, Jonathan M Davis wrote:
On Sunday, June 23, 2013 12:48:15 monarch_dodra wrote:
C++ doesn't allow it. I don't know about the rest.
Yes it does.
- Jonathan M Davis
Oh. Wow. That's news to me actually. I thought I new everything
about C++ ^^
On Sunday, June 23, 2013 12:48:15 monarch_dodra wrote:
> C++ doesn't allow it. I don't know about the rest.
Yes it does. I just tested it. This code compiles and runs just fine
#include
using namespace std;
class C
{
public:
static void foo()
{
cout << "I'm static!" << endl;
On Sunday, 23 June 2013 at 10:09:39 UTC, Jonathan M Davis wrote:
On Sunday, June 23, 2013 12:02:42 Namespace wrote:
> I don't see what's so terrible about it
It's bug prone.
class Foo {
public:
static void test1() { }
void test2() { }
}
Foo f;
f.test1(); /// Oh nice, that work
On Sunday, June 23, 2013 12:02:42 Namespace wrote:
> > I don't see what's so terrible about it
>
> It's bug prone.
>
> class Foo {
> public:
> static void test1() { }
> void test2() { }
> }
>
> Foo f;
> f.test1(); /// Oh nice, that works, f is not null.
> f.test2(); /// WTF? f is nul
I don't see what's so terrible about it
It's bug prone.
class Foo {
public:
static void test1() { }
void test2() { }
}
Foo f;
f.test1(); /// Oh nice, that works, f is not null.
f.test2(); /// WTF? f is null?
Also I don't know why I should call static methods from an
instance.
On Sunday, June 23, 2013 11:30:11 Jacob Carlborg wrote:
> On 2013-06-22 23:51, Timon Gehr wrote:
> > If that is the only problem then the solution is to allow overloading on
> > static, which is easy to do.
>
> You still need to call the static method on the class/struct if there's
> an ambiguity.
On 2013-06-22 23:51, Timon Gehr wrote:
If that is the only problem then the solution is to allow overloading on
static, which is easy to do.
You still need to call the static method on the class/struct if there's
an ambiguity.
--
/Jacob Carlborg
On 06/22/2013 10:20 PM, Jacob Carlborg wrote:
On 2013-06-22 19:11, monarch_dodra wrote:
I don't see what's so terrible about it: If A can do it, I don't see
what an instance of a couldn't?
The problem is that you cannot overload on "static". That is, have a two
methods with the same name, one
On 2013-06-22 19:11, monarch_dodra wrote:
I don't see what's so terrible about it: If A can do it, I don't see
what an instance of a couldn't?
The problem is that you cannot overload on "static". That is, have a two
methods with the same name, one being declared "static". Usually it's
possib
On Saturday, 22 June 2013 at 16:44:36 UTC, H. S. Teoh wrote:
On Sat, Jun 22, 2013 at 06:34:25PM +0200, Namespace wrote:
>but that's a problem caused by the fact that static functions
>can be
>called via an instance, and fixing that would mean making it
>illegal
>to call static functions on inst
On Sat, Jun 22, 2013 at 06:34:25PM +0200, Namespace wrote:
> >but that's a problem caused by the fact that static functions can be
> >called via an instance, and fixing that would mean making it illegal
> >to call static functions on instances (which I would love to have
> >happen but don't expect
but that's a problem caused by the fact that static functions
can
be called via an instance, and fixing that would mean making it
illegal to call
static functions on instances (which I would love to have
happen but don't
expect to ever happen).
- Jonathan M Davis
What was the reason for this
On Thursday, June 20, 2013 21:38:57 Namespace wrote:
> Yes that's obvious. My question is: is that intended? IMO this
> could cause bugs.
It's a natural result of how the implementation works. Checking for null would
just be extra overhead (Walter won't even do that for virtual functions which
_
Yes that's obvious. My question is: is that intended? IMO this
could cause bugs.
On 2013-06-20 21:17, w0rp wrote:
You are invoking a function effectively stored statically in a class
namespace. So you never actually dereference the null reference. You're
just calling a function that doesn't really have anything to do with the
reference. I prefer to tell it like it is and call
You are invoking a function effectively stored statically in a
class namespace. So you never actually dereference the null
reference. You're just calling a function that doesn't really
have anything to do with the reference. I prefer to tell it like
it is and call the static method with the cla
I had expected that the following code would crash:
It it intended?
import std.stdio;
class Foo {
public:
static void test1() { }
void test2() { }
}
void main()
{
Foo.test1();
/// Foo.test2(); crash as expected
Foo f;
f.test1(); ///
23 matches
Mail list logo