[Issue 4545] Alias to members possible without "this" instance
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Aug 7 07:01:34 PDT 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4545
--- Comment #3 from Jacob Carlborg <doob at me.com> 2010-08-07 07:01:32 PDT ---
(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.". 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.
> See also bug 2557.
>
> Applies to D1 as well, though new A must be cast. Moreover, you don't need to
> go through an alias - DMD 1.062 accepts even
> dg.funcptr = &A.foo;
I used an alias because an alias was used in the first example.
> But non-static members of structs/classes/unions are still compile-time
> entities, and they have properties.
--
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