[C++-sig] Re: (return_self_policy / return_arg): Keywors

David Abrahams dave at boost-consulting.com
Fri Jul 4 00:11:45 CEST 2003


[Nikolay, please leave a blank line between quotations for
readability.  Thanks!]

Nikolay Mladenov <nickm at sitius.com> writes:

> I've attached test files.
>
>> OK, I don't understand this.  Isn't the 2nd constructor redundant?
>
> Yes it is but, having it makes certain calls more efficient (it's
> cheating, in a way ), see the commented section in the py-file, may
> be def with args can be made so it is really redundant.

OK, I would like to see "irrelevancies" removed from the code for any
test case, though... unless you think the efficiency issue is closely
related to the keyword support, in which case you'll have to convince
me (please).

>> Why are you using no_init?  
>
> For the same reason, not that it makes sence for my first example,
> but in general, I want my most offsen called overload to be first in
> the list - so defined last.

That still doesn't explain why you'd want to use no_init.  Why not
just define the more-important constructor 2nd? 

>> Doesn't this stuff work for regular functions and member functions,
>> too?
>
> Yes it works, see the test.

Fantastic.

>> ...and shouldn't we get rid of the need to write the outer
>> "args(...)"?
> It is not necessary to have it, you can write 
> 	(arg("a") = (int)0, arg("b") = (double)0, arg("n") = std::string()))
> instead of
> 	args(arg("a") = (int)0, arg("b") = (double)0, arg("n") =
> std::string()))
> but you'll probably want
> 	args("a","b","c", arg("n") = std::string()))
> instead of
> 	(arg("a"), arg("b"), arg("c"), arg("n") = std::string()))

Understood... but is it really wise to give people more than One (And
Preferably Only One) Obvious Way To Do It?

I might be inclined to support only:

  args("a","b","c")

and:

  (arg("a"), arg("b"), arg("c"), arg("n") = std::string()))

Or even drop the 1st and go with

  (arg("a"), arg("b"), arg("c"))

Thoughts?

>> I suggest you write the documentation which would explain all this,
>
> Sure, but I think I'll wait a bit to see all of your comments:)

OK.

>> but posting informally is fine if you try to ensure that I don't have
>> to ask you lots more questions in order to understand it ;-)
>
> I hope this all makes sense to you.

It does.

In the examples, I'd prefer to see

                      arg("a") = int()
                    , arg("b") = double()
                    , arg("n") = std::string()

or 

                      arg("a") = 0
                    , arg("b") = 0.0
                    , arg("n") = std::string()

or 

                      arg("a") = 0
                    , arg("b") = 0.0
                    , arg("n") = ""

instead of 

                      arg("a") = (int)0
                    , arg("b") = (double)0
                    , arg("n") = std::string()

Aside from that and my previous comments, it looks scrumptious!

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com





More information about the Cplusplus-sig mailing list