Method pointers are *function* pointers?? Or delegates??

2012-05-18 Thread Mehrdad
My brain just exploded. Can someone explain what's going on? class Test { public void foo() { } } static assert(is(typeof(&Test.foo) == void function()));

Re: Method pointers are *function* pointers?? Or delegates??

2012-05-18 Thread Alex Rønne Petersen
On 18-05-2012 20:22, Mehrdad wrote: My brain just exploded. Can someone explain what's going on? class Test { public void foo() { } } static assert(is(typeof(&Test.foo) == void function())); Delegates. Pointer to member function + class instance. -- Alex Rønne Petersen a...@lycus.org http://

Re: Method pointers are *function* pointers?? Or delegates??

2012-05-18 Thread Andrei Alexandrescu
On 5/18/12 1:22 PM, Mehrdad wrote: My brain just exploded. Can someone explain what's going on? class Test { public void foo() { } } static assert(is(typeof(&Test.foo) == void function())); Looks like a bug. The assert should pass only if foo were static. Andrei

Re: Method pointers are *function* pointers?? Or delegates??

2012-05-18 Thread Mehrdad
On Friday, 18 May 2012 at 18:30:48 UTC, Andrei Alexandrescu wrote: On 5/18/12 1:22 PM, Mehrdad wrote: My brain just exploded. Can someone explain what's going on? class Test { public void foo() { } } static assert(is(typeof(&Test.foo) == void function())); Looks like a bug. The assert should

Re: Method pointers are *function* pointers?? Or delegates??

2012-05-18 Thread Mehrdad
On Friday, 18 May 2012 at 18:32:00 UTC, Mehrdad wrote: Okay I'll report it... hopefully it isn't just with my version though (a little different from official version). http://d.puremagic.com/issues/show_bug.cgi?id=8114

Re: Method pointers are *function* pointers?? Or delegates??

2012-05-18 Thread Steven Schveighoffer
On Fri, 18 May 2012 14:30:46 -0400, Andrei Alexandrescu wrote: On 5/18/12 1:22 PM, Mehrdad wrote: My brain just exploded. Can someone explain what's going on? class Test { public void foo() { } } static assert(is(typeof(&Test.foo) == void function())); Looks like a bug. The assert should

Re: Method pointers are *function* pointers?? Or delegates??

2012-05-18 Thread Mehrdad
On Friday, 18 May 2012 at 18:59:23 UTC, Steven Schveighoffer wrote: On Fri, 18 May 2012 14:30:46 -0400, Andrei Alexandrescu wrote: On 5/18/12 1:22 PM, Mehrdad wrote: My brain just exploded. Can someone explain what's going on? class Test { public void foo() { } } static assert(is(typeof(&T

Re: Method pointers are *function* pointers?? Or delegates??

2012-05-18 Thread Steven Schveighoffer
On Fri, 18 May 2012 15:17:28 -0400, Mehrdad wrote: On Friday, 18 May 2012 at 18:59:23 UTC, Steven Schveighoffer wrote: On Fri, 18 May 2012 14:30:46 -0400, Andrei Alexandrescu wrote: On 5/18/12 1:22 PM, Mehrdad wrote: My brain just exploded. Can someone explain what's going on? class Tes

Re: Method pointers are *function* pointers?? Or delegates??

2012-05-18 Thread Alex Rønne Petersen
On 18-05-2012 21:34, Steven Schveighoffer wrote: On Fri, 18 May 2012 15:17:28 -0400, Mehrdad wrote: On Friday, 18 May 2012 at 18:59:23 UTC, Steven Schveighoffer wrote: On Fri, 18 May 2012 14:30:46 -0400, Andrei Alexandrescu wrote: On 5/18/12 1:22 PM, Mehrdad wrote: My brain just exploded.

Re: Method pointers are *function* pointers?? Or delegates??

2012-05-18 Thread Andrei Alexandrescu
On 5/18/12 1:59 PM, Steven Schveighoffer wrote: On Fri, 18 May 2012 14:30:46 -0400, Andrei Alexandrescu wrote: On 5/18/12 1:22 PM, Mehrdad wrote: My brain just exploded. Can someone explain what's going on? class Test { public void foo() { } } static assert(is(typeof(&Test.foo) == void func

Re: Method pointers are *function* pointers?? Or delegates??

2012-05-18 Thread Daniel Murphy
"Mehrdad" wrote in message news:ifswigmcenyryxzyv...@forum.dlang.org... > On Friday, 18 May 2012 at 18:59:23 UTC, Steven Schveighoffer wrote: >> On Fri, 18 May 2012 14:30:46 -0400, Andrei Alexandrescu >> wrote: >> >>> On 5/18/12 1:22 PM, Mehrdad wrote: My brain just exploded. Can some

Re: Method pointers are *function* pointers?? Or delegates??

2012-05-18 Thread Mehrdad
On Saturday, 19 May 2012 at 01:37:54 UTC, Daniel Murphy wrote: No, that won't work in all cases due to the ordering of parameters, 'this' and the hidden struct pointer. Better than not working in /any/ cases lol. :P Maybe you can add a void* for the hidden struct parameter? idk...

Re: Method pointers are *function* pointers?? Or delegates??

2012-05-18 Thread Daniel Murphy
"Mehrdad" wrote in message news:sxiwbwuwvcjrlvpfs...@forum.dlang.org... > On Saturday, 19 May 2012 at 01:37:54 UTC, Daniel Murphy wrote: >> No, that won't work in all cases due to the ordering of parameters, >> 'this' and the hidden struct pointer. > > Better than not working in /any/ cases lol.

Re: Method pointers are *function* pointers?? Or delegates??

2012-05-18 Thread Mehrdad
On Saturday, 19 May 2012 at 02:38:11 UTC, Daniel Murphy wrote: I'd actually rather it /didn't/ work in any cases, and just returned void*. Well if that's an option then I like that too.

Re: Method pointers are *function* pointers?? Or delegates??

2012-05-19 Thread deadalnix
Le 19/05/2012 03:37, Daniel Murphy a écrit : "Mehrdad" wrote in message news:ifswigmcenyryxzyv...@forum.dlang.org... On Friday, 18 May 2012 at 18:59:23 UTC, Steven Schveighoffer wrote: On Fri, 18 May 2012 14:30:46 -0400, Andrei Alexandrescu wrote: On 5/18/12 1:22 PM, Mehrdad wrote: My bra

Re: Method pointers are *function* pointers?? Or delegates??

2012-05-19 Thread deadalnix
Le 18/05/2012 22:35, Andrei Alexandrescu a écrit : On 5/18/12 1:59 PM, Steven Schveighoffer wrote: On Fri, 18 May 2012 14:30:46 -0400, Andrei Alexandrescu wrote: On 5/18/12 1:22 PM, Mehrdad wrote: My brain just exploded. Can someone explain what's going on? class Test { public void foo() {

Re: Method pointers are *function* pointers?? Or delegates??

2012-05-22 Thread Steven Schveighoffer
On Fri, 18 May 2012 16:35:38 -0400, Andrei Alexandrescu wrote: On 5/18/12 1:59 PM, Steven Schveighoffer wrote: On Fri, 18 May 2012 14:30:46 -0400, Andrei Alexandrescu wrote: On 5/18/12 1:22 PM, Mehrdad wrote: My brain just exploded. Can someone explain what's going on? class Test { publ

Re: Method pointers are *function* pointers?? Or delegates??

2012-05-22 Thread Jacob Carlborg
On 2012-05-22 20:14, Steven Schveighoffer wrote: I agree, it's unsound. But so is this: int *blah = void; *blah = 5; It doesn't mean that the language should forbid it, or that the compiler isn't implemented as designed. At the *very least*, the address to member function operation should be

Re: Method pointers are *function* pointers?? Or delegates??

2012-05-22 Thread Steven Schveighoffer
On Tue, 22 May 2012 14:28:33 -0400, Jacob Carlborg wrote: On 2012-05-22 20:14, Steven Schveighoffer wrote: I would suggest that it should be: function(Test this) with the 'this' being mangled into the name, and affect the calling convention. Structs would be function(ref Test this). And co

Re: Method pointers are *function* pointers?? Or delegates??

2012-05-22 Thread Jacob Carlborg
On 2012-05-22 20:35, Steven Schveighoffer wrote: It needs to be possible to compose delegates: class Foo { void foo () {}; } void delegate () dg; dg.funcptr = &Foo.foo; Error, cannot cast function of type void function(Foo this) to void function(void *this) dg.funcptr = cast(void function(

Re: Method pointers are *function* pointers?? Or delegates??

2012-05-22 Thread Andrei Alexandrescu
On 5/22/12 1:14 PM, Steven Schveighoffer wrote: I agree, it's unsound. But so is this: int *blah = void; *blah = 5; It doesn't mean that the language should forbid it, or that the compiler isn't implemented as designed. Initialization with void is a feature. My example shows the fail of a f

Re: Method pointers are *function* pointers?? Or delegates??

2012-05-22 Thread Andrei Alexandrescu
On 5/22/12 4:05 PM, Steven Schveighoffer wrote: On Tue, 22 May 2012 15:29:10 -0400, Andrei Alexandrescu wrote: On 5/22/12 1:14 PM, Steven Schveighoffer wrote: I agree, it's unsound. But so is this: int *blah = void; *blah = 5; It doesn't mean that the language should forbid it, or that the

Re: Method pointers are *function* pointers?? Or delegates??

2012-05-22 Thread Steven Schveighoffer
On Tue, 22 May 2012 15:29:10 -0400, Andrei Alexandrescu wrote: On 5/22/12 1:14 PM, Steven Schveighoffer wrote: I agree, it's unsound. But so is this: int *blah = void; *blah = 5; It doesn't mean that the language should forbid it, or that the compiler isn't implemented as designed. Init