[Issue 4545] Alias to members possible without "this" instance

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Aug 7 07:21:22 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=4545



--- Comment #4 from Stewart Gordon <smjg at iname.com> 2010-08-07 07:21:22 PDT ---
(In reply to comment #3)
> (In reply to comment #2)
> > I'm not sure.  The existence of .funcptr seems to contradict
> > 
> > http://www.digitalmars.com/d/1.0/type.html#delegates
> > "There are no pointers-to-members in D, but a more useful concept called
> > delegates are supported."
> 
> Just after that it says: "Delegates are an aggregate of two pieces of data: an
> object reference and a function pointer.".

It really should say "a pointer to a non-static member function".

> You must always have a pointer to a
> member, then you add a context and gets a delegate. How about static members,
> you can have pointers to those, regular function pointers. I don't know why the
> docs are written like that. Probably because the concept is a little different
> compared to C++'s member pointers. D's delegates are basically just syntax
> sugar for a C++'s member pointer and a instance of the same class.

No, because delegate types don't care the least what class the function is a
member of.  This is why they're more useful - whatever is using the delegate
need not know anything about the class, and so (for instance) a library can use
a delegate just like a plain function pointer.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list