Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!think.com!spool.mu.edu!uunet!fernwood!lia!jgro From: jgro@lia (Jeremy Grodberg) Newsgroups: comp.lang.c++ Subject: Re: cast of a bound pointer: why ? Message-ID: <1991Jun14.201641.688@lia> Date: 14 Jun 91 20:16:41 GMT References: <1991Jun11.191016.9873@beaver.cs.washington.edu> Reply-To: jgro@lia.com (Jeremy Grodberg) Lines: 31 In article <1991Jun11.191016.9873@beaver.cs.washington.edu> pauld@cs.washington.edu (Paul Barton-Davis) writes: >[...] >My understanding of this position is that it really boils down to an >syntactic nicety: > > ptr to member function != ptr to function > >Can anyone explain the necessity for this distinction, and perhaps >more importantly, can anyone comment on the possibility that it will >no longer be possible to use this construct ? The difference is that member functions have an implied (or hidden) first argument which is the "this" pointer. Thus a pointer to a member function of class T taking an int is really a pointer to a function taking a pointer to an object of class T, and an int. Thus, member functions are not interchangable with non-member functions (the exception being static member functions, which do *not* take a "this" pointer). You could argue that you should be able to cast a member function to a non-member function with an object pointer, but a) this would not buy you much, if anything, and b) it would destroy the abstraction of member functions being associated with object, and c) (I believe) the position of the "this" pointer in the function call is implementation dependant. So conversions from pointer to member function to pointer to non-member function (and vice versa) will be forbidden as soon as is practical. -- Jeremy Grodberg "Show me a new widget that's bug-free, and I'll show jgro@lia.com you something that's been through several releases."