source code size metric: Python and modern C++

Brian Quinlan brian at sweetapp.com
Tue Dec 3 15:34:26 EST 2002


Cheers,
Brian 

> -----Original Message-----
> From: python-list-admin at python.org
[mailto:python-list-admin at python.org]
> On Behalf Of David Abrahams
> Sent: Tuesday, December 03, 2002 12:00 PM
> To: Brian Quinlan
> Cc: python-list at python.org
> Subject: Re: source code size metric: Python and modern C++
> 
> Brian Quinlan <brian at sweetapp.com> writes:
> 
> > David Abrahams wrote:
> >> The type-safe version could easily look like this instead:
> >>
> >>    ServerProxy
> > s("http://www.sweetapp.com/cgi-bin/xmlrpc-test/rpc1.py");
> >>    int result = s.call_method<int>("add", 2, 3);
> >>
> >> That's not too bad.
> >
> > You can only do this in the special case where all the arguments and
the
> > result are of the same type.
> 
> Not true.
> 
>     struct ServerProxy
>     {
>        ...
>        // use a family of these with different arities
>        template <class R, class A1, class A2>
>        R call_method(char const* name, A1 a1, A2 a2);
>        ...
>     };
> 
> > Do I really have to pick another example to demonstrate this?
> 
> It's up to you, bubba.

Now all you've done is generalize it so that any combination of 2
arguments will work. XML-RPC methods can accept an arbitrary number of
arguments of mixed type. Is there a way to templatize that?

You could do the following:

Method<float> method("add");
method << 5 << 5.6;
method.do() 

Cheers,
Brian





More information about the Python-list mailing list