September 09, 2015
On Wednesday, 9 September 2015 at 18:55:18 UTC, Walter Bright wrote:
> On 6/10/2013 7:33 AM, Manu wrote:
>> [...]
>
> Sorry to say, your n.g. poster is back to its old tricks :-)

On 6/10/2013
That was 2 years ago.
September 09, 2015
On Wednesday, 9 September 2015 at 18:50:45 UTC, Walter Bright wrote:
> On 6/7/2013 4:21 PM, Manu wrote:
>> So from my dconf talk, I detailed a nasty hack to handle member function
>> pointers in D.
>
> https://www.digitalmars.com/articles/b68.html

Here's on automatic version

import std.traits : Parameters;

enum MemberFunc(alias Type, string member) = (ref Type self, Parameters!(__traits(getMember, Type, member)) args) => mixin(q{self.} ~ member ~ q{(args)});

unittest
{
    static struct A
    {
        bool test;
        void b(int arg)
        {
            test = arg == 4;
        }
    }

    A a;
    auto func = MemberFunc!(A, "b");
    func(a,4);
    assert(a.test);
}

September 09, 2015
On Wednesday, 9 September 2015 at 20:18:06 UTC, Freddy wrote:
> enum MemberFunc(alias Type, string member) = (ref Type self, Parameters!(__traits(getMember, Type, member)) args) => mixin(q{self.} ~ member ~ q{(args)});

Whoops the alias wasn't needed

enum MemberFunc(Type, string member) = (ref Type self, Parameters!(__traits(getMember, Type, member)) args) => mixin(q{self.} ~ member ~ q{(args)});

September 09, 2015
On 9/9/2015 1:17 PM, Freddy wrote:
> On Wednesday, 9 September 2015 at 18:55:18 UTC, Walter Bright wrote:
>> On 6/10/2013 7:33 AM, Manu wrote:
>>> [...]
>>
>> Sorry to say, your n.g. poster is back to its old tricks :-)
>
> On 6/10/2013
> That was 2 years ago.

Woops! I didn't notice. My reader sorts things based on the date of the last post.
September 09, 2015
On Wednesday, 9 September 2015 at 18:33:41 UTC, Prudence wrote:
> On Tuesday, 27 May 2014 at 12:21:40 UTC, d coder wrote:
>> [...]
>
> What's the current state of this? I'm in need of such behavior for win32 interop.
>
> I'm thinking that one can make the above code more general by using it in a mixin and automatically generating the funcptr signature:
>
>
> import std.stdio;
> import std.concurrency;
>
> extern (C) int getch();
> import std.string;
>
>
> template FancyDelegate(O, D)
> {
> 	const char[] FancyDelegate = "union "~O.stringof~"Delegate { "~D.stringof~" dg; struct { "~O.stringof~"* ptr; "~D.stringof.replace("delegate(", "function("~O.stringof~",").replace(",)", ")")~" funcptr; } }";	
> 	//const char[] FancyDelegate = "union "~O.stringof~"Delegate { "~D.stringof~" dg; struct { "~O.stringof~"* ptr; "~D.stringof.replace("delegate(", "function(")~" funcptr; } }";	
> }
>
> class X
> {
> 	public int z = 2;
> 	public void foo(int x)
> 	{
> 		//writeln(this.z*x);
> 		writeln(x);
> 	}
> }
>
> void delegate(int) dg;
>
> mixin(FancyDelegate!(X, typeof(dg)));
>
>
> void main()
> {
>
> 	auto xX = new X();
> 	XDelegate x;
> 	x.dg = &xX.foo;
> 	
> 	//x.dg(3);
> 	x.ptr = &xX;
> 	x.funcptr(xX, 5);
> 	//x.funcptr(5);
>
> 	
> 	getch();
> }
>
> Unfortunately this fails when entering the function. I've tried various things(passing &xX, etc..., passing nothing(the comments, etc.)
>
> I thought a delegate, when called, was called like a member function? It seems that a delegate is some magic black box that we can't emulate in any way shape or form due to the calling conventions used?

struct S {
	void fun() { writeln("fun" ); }
}

class C {
	void fun() { writeln("fun" ); }
}

void main(string[] args) {
	S s;
	void delegate() fn1 = &s.fun;
	fn1();

	C c = new C();
	void delegate() fn2 = &c.fun;
	fn2();

	void delegate() fn3;
	fn3.ptr = cast(void*)&s;
	fn3.funcptr = &S.fun;
	fn3();

	void delegate() fn4;
	fn4.ptr = cast(void*)c;
	fn4.funcptr = &C.fun;
	fn4();
}
September 10, 2015
On 10 September 2015 at 04:55, Walter Bright via Digitalmars-d <digitalmars-d@puremagic.com> wrote:
> On 6/10/2013 7:33 AM, Manu wrote:
>>
>> [...]
>
>
> Sorry to say, your n.g. poster is back to its old tricks :-)

We've resolved this issue since 6/10/2013 no? ;)
September 10, 2015
On 9/9/2015 6:52 PM, Manu via Digitalmars-d wrote:
> We've resolved this issue since 6/10/2013 no? ;)


:-)
September 10, 2015
On Thursday, 10 September 2015 at 01:52:17 UTC, digitalmars.D wrote:
> On 10 September 2015 at 04:55, Walter Bright via Digitalmars-d <digitalmars-d@puremagic.com> wrote:
>> On 6/10/2013 7:33 AM, Manu wrote:
>>>
>>> [...]
>>
>>
>> Sorry to say, your n.g. poster is back to its old tricks :-)
>
> We've resolved this issue since 6/10/2013 no? ;)

In the web forum, this post shows up as having author "digitalmars.D", not even "Manu via Digitalmars-d" like your posts normally do and definitely not "Manu" like it should.

CyberShadow?
September 10, 2015
On Thursday, 10 September 2015 at 16:18:13 UTC, John Colvin wrote:
> On Thursday, 10 September 2015 at 01:52:17 UTC, digitalmars.D wrote:
>> On 10 September 2015 at 04:55, Walter Bright via Digitalmars-d <digitalmars-d@puremagic.com> wrote:
>>> On 6/10/2013 7:33 AM, Manu wrote:
>>>>
>>>> [...]
>>>
>>>
>>> Sorry to say, your n.g. poster is back to its old tricks :-)
>>
>> We've resolved this issue since 6/10/2013 no? ;)
>
> In the web forum, this post shows up as having author "digitalmars.D", not even "Manu via Digitalmars-d" like your posts normally do and definitely not "Manu" like it should.
>
> CyberShadow?

Heh. My fault. Fixed (though it'll stick for that post in some views).
September 10, 2015
On Thursday, 10 September 2015 at 16:24:52 UTC, Vladimir Panteleev wrote:
> Heh. My fault. Fixed (though it'll stick for that post in some views).

Now the main index says: "Unexpected end of input when converting from type string to type long".