Boost logo

Boost :

From: David Abrahams (david.abrahams_at_[hidden])
Date: 2002-03-08 09:31:45


----- Original Message -----
From: "vesa_karvonen" <vesa_karvonen_at_[hidden]>

> hmm... I've tried to use the same one character names for every macro
> parameter used for the same purpose in the library, but there are
> still many exceptions to the rules. I'll try to fix those exceptions
> and add a separate page that explicitly explains the naming of
> parameters.

I'm sorry; I don't see how that's relevant. My point was that the user
needs to choose something to be passed for R when she invokes
BOOST_PP_LIST_FOR_EACH_I(). In general, almost anything will do.

> The R and D parameters are actually "generated" by BOOST_PP_FOR() and
> BOOST_PP_WHILE(), respectively, and passed to the user written macro.
> Both R and D serve as recursion depth and are an unfortunate
> implementation detail necessitated by the C++ preprocessor. The R and
> D parameters can often be ignored by the user.

Not exactly; you have to pass them something.

> The P parameter is a parameter specified by the user and is passed to
> the user written macro. The P parameter serves as a way to provide
> context for the user written macro. Many user written macros do not
> need the context and the user can pass almost anything (e.g. 'ignore'
> or 'dummy') as the P parameter. I personally recommend '_' (a single
> underscore), because it is often used for the same or similar purpose
> in functional programming languages.

That's a nice explanation.

> > You could look at
> > boost/python/converter/from_python_data.hpp for what I ended up
> > with.
>
> That looks quite nice.
>
> As this case requires iteration over types (which can be done using
> template metaprogramming), and is not a specialization of a template
> (which can not be done using template metaprogramming), I think that
> it should be possible to achieve the same effect using only MPL,
> which might be preferable.

Trust me, the PP library was a last resort. It was too slow with various
EDG compilers when I just used template metaprogramming.

-Dave


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