Article View: comp.std.c++
Article #3553Re: Generic Object Callbacks
From: Shalom Reich
Date: Thu, 29 Feb 1996 16:34
Date: Thu, 29 Feb 1996 16:34
45 lines
2757 bytes
2757 bytes
Ben Jones wrote:
>
> Anders Lindback (alindbac@sw.seisy.abb.se) wrote:
> : In article <4gsi2p$905@bcarh8ab.bnr.ca>,
> : brian (b.c.) white <bcwhite@bnr.ca> wrote:
> : >
> : >>What is needed is the ability to use member functions as callbacks
> : >>without any constraint on the type of the object they are invoked on.
> : >>This is possible in C++ only by using various implementation-dependent
> : >>hacks to escape the type system, because the language does not provide
> : >>any way to express such a construct.
> : >
>
> The point we have been making is that there is a trivial way to extend
> the C++ language to provide for completely typesafe callbacks which
> are simple to use and which will dramatically improve the clarity
> of programs.
>
I don't seem to understand the discussion in this thread. Yet it seems to generate
some strong opinions. So, . . .
The routine that will issue the callback (let us call it the driver) needs to use a
stored pointer. The argument is that the stored pointer should be to a member function.
Why isn't it good enough for the stored pointer to be a pointer to the object and then
the driver will only need to say "object->callback();" in order to call the proper routine.
The usual virtual function semantics would take care of any inheritance hierarchy.
If the driver could deal directly with the address of a non-static member function
how would the "this" parameter be supplied by the caller?
The X example seems to be showing an inteface between a C environment and a C++
environment. Is that the real problem?
Am I missing something here?
Shalom Reich
[ comp.std.c++ is moderated. To submit articles: Try just posting with your
newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]
Technical Details
Message-ID:
<3135C73D.5570@acf4.nyu.edu>Path:
arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamageReferences:
<pgpmoose.199602221531.14635@isolde.mti.sgi.com> <4gsi2p$905@bcarh8ab.bnr.ca> <4guh9e$jt6@sdaw04.seinf.abb.se> <4h1pb6$n19@news2.cais.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamage From: Shalom Reich <sqr1874@acf4.nyu.edu> Newsgroups: comp.std.c++ Subject: Re: Generic Object Callbacks Date: 29 Feb 1996 16:34:30 GMT Organization: Bankers Trust Company Approved: clamage@eng.sun.com (comp.std.c++) Message-ID: <3135C73D.5570@acf4.nyu.edu> References: <pgpmoose.199602221531.14635@isolde.mti.sgi.com> <4gsi2p$905@bcarh8ab.bnr.ca> <4guh9e$jt6@sdaw04.seinf.abb.se> <4h1pb6$n19@news2.cais.com> NNTP-Posting-Host: taumet.eng.sun.com Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Nntp-Posting-Host: algsvw0058.btco.com X-Mailer: Mozilla 2.0GoldB1 (WinNT; I) X-Lines: 37 Content-Length: 1621 Originator: clamage@taumet