Boost logo

Boost :

From: Daniel Wallin (dalwan01_at_[hidden])
Date: 2004-11-23 03:33:33


Thomas Witt wrote:
>
> Hi,
>
> I was going to provide a (late) review for the named parameter lib, but
> I have some questions before I can do that.
>
> 1) I find the use of the name "keyword" for the type of the named
> parameter somehow odd. It does not seem to fit with what I associate
> with keywords. What's the rationale behind that choice.

AFAIK "keyword arguments" is a common name for this. Python for instance
uses this term.

> 2) The docs give the following example for mixing named and positional
> parameters:
>
> foo("bar", 3.14f);
> foo(value = 6.28f, "baz")
>
> Should print:
>
> bar = 3.14
> baz = 6.28
>
> I believe the parameter deduction in this case is too smart.

Yes, in fact it's wrong and won't compile (name has no value in the
second call). That will be fixed in the docs.

> Is there a way for the user of the library to enforce a rule like "No
> positional param after named params" on a case by case basis?

I think we could implement something like that. I have to think about it
a little.

> 3) Section 5 has the following example
>
> // implementation of bar()
> template <class Params>
> void bar_impl(Params const& params)
> {
> // Extract arguments
> float x_ = params[x];
> float theta_ = params[theta | pi];
> float span = params[span || boost::bind(default_span, x_, theta_)];
> //!! ^^^^ ^^^^
> ...
> }
>
> IIUC this does not work. I assume the second span should refer to a
> named paramter object. I think it refers to the local span object.
> Did I miss something?

Yes, you are right. The local should be named span_.

-- 
Daniel Wallin

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