----- Original Message ----- From: "Rob Stewart" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, May 22, 2003 8:15 PM Subject: Re: [boost] Re: Formal Review: Command Line & Config library
> From: "James Curran" <[EMAIL PROTECTED]> > > Chuck Messenger wrote: > > >> * add_options() should use references rather than pointers > > > > > "Pointer for return value" is C semantics. In C++, > > > pointers denote optional values. Non-const references are for return > > > values. > > > > I disagree *strongly*. In C and C++, the address-of syntax clearly > > indicates that this is a value that will be changed. Your suggestion of > > using a non-const reference would require me to check the header file to > > find the signature of _every_single_F#$^%ing_function to figure out which > > parameters are changed and which one's aren't. (particularly in the case of > > Disagree strongly all you want, but I only use pointers to > indicate optional arguments and to pass references (general > meaning of the word) to objects that are expected to outlive the > object to which they are given (usually in the ctor). In the > former case, the argument may be null so I check for that case. > In the latter, I often use RCSPs, but not always. > > I don't use non-const reference parameters often (and when I do > they are always the first argument(s)). I find they work > intuitively. You see, such functions always indicate, by their > very name, that they are providing a value, so the name quite > reasonably documents the output parameter. > > Using pointers in this context would be counterintuitive to me. > > Ultimately, someone will be disappointed. Allow me to provide a few arguments in favor of using non-const reference instead of pointer, that may be will help reaching a conclusion (when to use pointer and reference is mainly a matter of style & guideline, therefore leading to 'endless' discussion). Boost defines some guidelines. Among those are references to Scott Meyer 'Effective C++' series. While no requirement is made to follow the guidelines contained in the book the suggestion is made. Scott Meyer provides some guidelines on when to use reference and pointer. In the current case, it would sum up to 'use pointer when the parameter can be optional, in which case a null pointer will be passed'. As a user of boost library, I would expect that guideline to be followed (to my knowledge, this is the case for most (all ?) existing boost libraries). Also, the add_options() usage as some similarity with Boost.Tuple tie() function, which use reference. Renaming may help if you fell that the current name isn't clear enough (tie_options ?) Regards, Baptiste. > -- > Rob Stewart [EMAIL PROTECTED] > Software Engineer http://www.sig.com > Susquehanna International Group, LLP using std::disclaimer; > _______________________________________________ > Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost