digitalmars.D - casting interface to void*
- Ben Hinkle (8/8) May 09 2005 Walter, given an interface reference x can we make cast(void*)x actually...
- Walter (5/13) May 10 2005 interfaces
- Ben Hinkle (8/22) May 10 2005 When would a D program need that? Can't they reconstruct the pointer fro...
- Walter (8/19) May 10 2005 just
Walter, given an interface reference x can we make cast(void*)x actually perform cast(void*)cast(Object)x? Similarly casting from void* to an interface X would actually perform cast(X)cast(Object). That way interfaces could be used as keys to assoc arrays and in general it would make interfaces operate more uniformly with objects. Plus it would then be true that Object obj = x; cast(void*)x === cast(void*)obj;
May 09 2005
"Ben Hinkle" <ben.hinkle gmail.com> wrote in message news:d5p4sc$6dk$1 digitaldaemon.com...Walter, given an interface reference x can we make cast(void*)x actually perform cast(void*)cast(Object)x? Similarly casting from void* to an interface X would actually perform cast(X)cast(Object). That wayinterfacescould be used as keys to assoc arrays and in general it would make interfaces operate more uniformly with objects. Plus it would then be true that Object obj = x; cast(void*)x === cast(void*)obj;I'm uneasy about doing that because then that removes the ability to just know what the actual pointer is.
May 10 2005
"Walter" <newshound digitalmars.com> wrote in message news:d5r00o$1m66$1 digitaldaemon.com..."Ben Hinkle" <ben.hinkle gmail.com> wrote in message news:d5p4sc$6dk$1 digitaldaemon.com...When would a D program need that? Can't they reconstruct the pointer from the classinfo if they really want to know the interface offset? If an interface is another view on an object one would imagine having the same pointer for the Object view as for the interface views would be desirable. The fact that interfaces require different pointers should be an implementation detail not visible to the user (preferably).Walter, given an interface reference x can we make cast(void*)x actually perform cast(void*)cast(Object)x? Similarly casting from void* to an interface X would actually perform cast(X)cast(Object). That wayinterfacescould be used as keys to assoc arrays and in general it would make interfaces operate more uniformly with objects. Plus it would then be true that Object obj = x; cast(void*)x === cast(void*)obj;I'm uneasy about doing that because then that removes the ability to just know what the actual pointer is.
May 10 2005
"Ben Hinkle" <bhinkle mathworks.com> wrote in message news:d5r23j$1obd$1 digitaldaemon.com..."Walter" <newshound digitalmars.com> wrote in message news:d5r00o$1m66$1 digitaldaemon.com...justI'm uneasy about doing that because then that removes the ability toI need it when debugging <g>. D needs to support ways to get at the underlying representation of things. The void* cast is how that's done with references.know what the actual pointer is.When would a D program need that?Can't they reconstruct the pointer from the classinfo if they really want to know the interface offset? If an interface is another view on an object one would imagine having the same pointer for the Object view as for the interface views would be desirable. The fact that interfaces require different pointers should be an implementation detail not visible to the user (preferably).But it's an important detail. I think the functionality you need is supported with the cast(Object).
May 10 2005