🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #3569

Re: Generic Object Callbacks

#3569
From: Rich Hickey
Date: Sat, 02 Mar 1996 16:56
36 lines
2401 bytes
In message <4h5j7b$1ur@bcarh8ab.bnr.ca> - "ian (i.) willmott" 
<willmott@bnr.ca> writes:

:>The original article (this has expired on my site and possibly others
:>as well; maybe I should repost it) suggests a new type
:>"pointer-to-bound-member-function" which would encapsulate an object
:>pointer and a pointer to a member function of that class.

Having previously considered the suggestion you proposed and forced to solve 
the problem in current language, and with a lot of experience using a
current-language solution, I feel it is actually preferable to the extension 
you propose in the following areas:

A)It is more type-flexible. By that I mean it is possible to produce a 
callback system that is type-safe, yet tolerant of type differences in the 
caller/callee signatures that are either implicitly convertible or can be 
ignored. For example if the caller requires a function to which it can pass 
an int and from which it expects nothing, using my library it is possible to 
bind the callback to a function that takes an int and returns an int (return 
value is ignored), or takes a long and returns void (compiler implicitly 
converts int->long). Once you get involved with polymorphism this becomes 
critical: caller passes ptr-to-derived, callee accepts ptr-to-base. Any 
language extension approach would have the rigidity normally associated with 
pointers-to-functions, i.e. exactly matching signatures required. 

B)It is easier to extend; to things like callbacks with stored arguments 
etc.

Rich
---
[ To submit articles: try just posting with your news-reader.
                      If that fails, use mailto:std-c++@ncar.ucar.edu
  FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html
  Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html
  Comments? mailto:std-c++-request@ncar.ucar.edu.
]
Technical Details
Message-ID: <4h9ii0$3mlq@news-s01.ny.us.ibm.net>
Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back

Show Full Headers
Complete Article Headers
From: hickeyr@ibm.net (Rich Hickey)
Message-ID: <4h9ii0$3mlq@news-s01.ny.us.ibm.net>
X-Original-Date: 2 Mar 1996 13:30:39 GMT
Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back
Date: 02 Mar 96 16:56:53 GMT
Approved: fjh@cs.mu.oz.au
Organization: -
Newsgroups: comp.std.c++
Subject: Re: Generic Object Callbacks
X-Newsreader: NeoLogic News for OS/2 [version: 4.2]
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBFAgUBMTh+FOEDnX0m9pzZAQFozgF/ZLcEAv/k/g4xYDhyRcRszBjvJ6SWHCwd
 l7oVEFxvzNvuu/WZUMoIEJp09yf8lQ9h
 =Xbtu