Python from Wise Guy's Viewpoint
Jon S. Anthony
j-anthony at rcn.com
Sat Oct 25 18:33:27 EDT 2003
gt5163b at prism.gatech.edu (Brian McNamara!) writes:
> j-anthony at rcn.com (Jon S. Anthony) once said:
> >gt5163b at prism.gatech.edu (Brian McNamara!) writes:
> >
> >> boost::tuple to then generalize things. (Indeed, using such libraries,
> >> you can simulate "apply" rather convincingly. But somewhere under the
> >> hood, someone has to have written N different overloads for 0-arg,
> >> 1-arg, ... N-arg, up to some fixed ("large enough") N.)
> >
> >That's not actually good enough. You also have to have overloads for
> >all the possible types for 1-arg, ..., N-arg. Actually it's worse
> >than that - the set of types is not closed, so even in principle this
> >won't work.
>
> I'm not sure I understand you, but if I do, then "templates" take care
> of this. That is, we'd write (e.g. for the 3-arg case):
>
> template <class A, class B, class C>
> Result someFunc( A a, B b, C c ); // fudging "Result" for simplicity
>
> which means that someFunc works "forall" types A, B, and C.
No, it means for any _instantiations_ of types A, B, and C, this will
(probably) give a runable function back.
/Jon
More information about the Python-list
mailing list