 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Ben Hutchings Guest
|
Posted: Thu Apr 01, 2004 4:10 pm Post subject: Defect report: Default modes missing from basic_fstream memb |
|
|
[ Note: Forwarded to C++ Committee. -sdc ]
The second parameters of the non-default constructor and of the open
member function for basic_fstream, named "mode", are optional
according to the class declaration in 27.8.1.11 [lib.fstream]. The
specifications of these members in 27.8.1.12 [lib.fstream.cons] and
27.8.1.13 lib.fstream.members] disagree with this, though the
constructor declaration has the "explicit" function-specifier implying
that it is intended to be callable with one argument.
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
|
|
| Back to top |
|
 |
Pete Becker Guest
|
Posted: Sun Apr 04, 2004 5:24 pm Post subject: Re: Defect report: Default modes missing from basic_fstream |
|
|
Ben Hutchings wrote:
| Quote: |
[ Note: Forwarded to C++ Committee. -sdc ]
The second parameters of the non-default constructor and of the open
member function for basic_fstream, named "mode", are optional
according to the class declaration in 27.8.1.11 [lib.fstream]. The
specifications of these members in 27.8.1.12 [lib.fstream.cons] and
27.8.1.13 lib.fstream.members] disagree with this, though the
constructor declaration has the "explicit" function-specifier implying
that it is intended to be callable with one argument.
|
Well, sort of. The underlying notion is that you can't repeat a default
argument:
class C
{
public:
void f(int i = 3);
void g(int i = 3);
};
void C::f(int i = 3) // error
{
}
void C::g(int i) // correct: doesn't repeat default argument
{
}
The style adopted in the standard is to make class and template synopses
look pretty much like definitions, and for the detailed descriptions of
the functions to begin with declarations that look more like the actual
function definition. So the above class would be documented in the
standard like this:
1.1 Class C
class C
{
public:
void f(int i = 3);
void g(int i = 3);
};
1.1.1 C members
void C::f(int i)
(description goes here)
void C::g(int i)
(description goes here)
In small examples like this it's clear what's going on. In larger ones
(like basic_fstream) it's much easier to lose track of the default
arguments. On the other hand, repeating default arguments (or mentioning
them in the description) means that the same information is presented
twice, leading to the same kind of maintenance problems as having two
functions in your program that are supposed to do the same thing: it's
easy to change one and forget about the other.
--
Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
|
|
| Back to top |
|
 |
Ben Hutchings Guest
|
Posted: Mon Apr 05, 2004 6:34 pm Post subject: Re: Defect report: Default modes missing from basic_fstream |
|
|
Pete Becker wrote:
| Quote: | Ben Hutchings wrote:
[ Note: Forwarded to C++ Committee. -sdc ]
The second parameters of the non-default constructor and of the open
member function for basic_fstream, named "mode", are optional
according to the class declaration in 27.8.1.11 [lib.fstream]. The
specifications of these members in 27.8.1.12 [lib.fstream.cons] and
27.8.1.13 lib.fstream.members] disagree with this, though the
constructor declaration has the "explicit" function-specifier implying
that it is intended to be callable with one argument.
Well, sort of. The underlying notion is that you can't repeat a default
argument:
|
Sure.
<snip>
| Quote: | The style adopted in the standard is to make class and template synopses
look pretty much like definitions, and for the detailed descriptions of
the functions to begin with declarations that look more like the actual
function definition.
|
That may have been the intent, but it doesn't seem to have happened.
| Quote: | So the above class would be documented in the standard like this:
1.1 Class C
class C
{
public:
void f(int i = 3);
void g(int i = 3);
};
1.1.1 C members
void C::f(int i)
(description goes here)
void C::g(int i)
(description goes here)
|
The standard never (so far as I can see) uses qualified names in the
descriptions of member functions. It also uses the "explicit" and
"virtual" function specifiers in some descriptions (I counted 30 and
10 instances respectively) though they are not allowed in out-of-line
member function definitions. I'm quite happy with this and I'd be
happier still if those function specifiers were consistently repeated
in the descriptions.
| Quote: | In small examples like this it's clear what's going on. In larger ones
(like basic_fstream) it's much easier to lose track of the default
arguments. On the other hand, repeating default arguments (or mentioning
them in the description) means that the same information is presented
twice, leading to the same kind of maintenance problems as having two
functions in your program that are supposed to do the same thing: it's
easy to change one and forget about the other.
|
I'm not sure what your argument is here. If you are saying that the
default arguments shouldn't be repeated so that there is isn't
duplication, I would disagree because the parameter types and names
have to be duplicated anyway. If you are saying that the repetition
*has* led to an error in this case, I would agree that this seems to
be a reasonable explanation.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|