Boost logo

Boost :

From: Kevlin Henney (kevlin_at_[hidden])
Date: 2000-11-22 14:37:53


In message <8vgkjo+102eg_at_[hidden]>, William Kempf <sirwillard_at_my-
deja.com> writes
>I've not looked at Jesse's new code yet, but Doug's code doesn't seem
>to open up the possiblity of runtime errors that you suggest.
>Neither does it require that any parameters or other types be default
>constructible. Care to elaborate on the problems you think you see?

The compile-time interface to the callback class offers versions of
operator() that cannot be satisfied at runtime.

>As for why it's desirable... it eliminates redundant information from
>the declaration. Why should you have to specify the number of
>parameters when you declare the type with explicit parameters? It's
>just cleaner to say:
>
>callback<void, int, float> cb;
>
>instead of:
>
>callback2<void, int, float> cb;

I understand that the syntax is desirable, but I don't think it should
be at the expense of safety.

It should be possible, with appropriate specialisations, to make the
unwanted overloads of the callback unusable for a given number of
arguments.

Another thought: Would it be possible to do a little currying to wrap up
the way that extra arguments are handled internally? This would have the
benefit of (1) enforcing only legal use, (2) simplifying the
implementation, and (3) keeping the size of classes and number of
virtuals flying around to a minimum.

Kevlin
____________________________________________________________

  Kevlin Henney phone: +44 117 942 2990
  Curbralan Limited mobile: +44 7801 073 508
  mailto:kevlin_at_[hidden] fax: +44 870 052 2289
  http://www.curbralan.com
____________________________________________________________


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk