|
Boost : |
From: Jens Maurer (Jens.Maurer_at_[hidden])
Date: 2000-11-17 16:18:30
William Kempf wrote:
> 1. Need to allow traditional functor types as the callback so that
> function pointers, standard functors, hand coded functors and Lambda
> Library style functors can all be used with relative ease.
Any lamda library should be able to deal with all these.
For me, it is important to have a separation between
"describing the thing which should be executed" and "delayed
execution of some thing". The design should be re-usable for
ScopeGuard, except that the latter has a slightly different
idea of the interface to "delayed execution of something".
(That's ok, it has a different purpose as well.) And, as
mentioned elsewhere, it is also re-usable for creating a thread
and passing in the thing which is to be execute in a separate
thread.
This, I believe, will cut down in code-size for the callback stuff.
Except that there is the variation in the number of parameters
which C++ cannot express in a general way.
> 2. The callback type(s) should be templatized on the return type and
> argument types, but not on the functor type to simplify useage.
Yes, very important for GUI-style callbacks, for example.
One implementation issue: If you use a smart-pointer approach for
your callbacks, please write (or re-use) a generic smart pointer and
wrap your stuff in it. For example, if you want to use an intrusive
smart pointer (because you have full control of all classes ever
controlled by the smart pointer), please define the concept and its
interface separately.
Keep orthogonal things orthogonal. Thanks. :-)
Jens Maurer
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk