Use of 'unsigned' in interfaces [was: Re: svn commit: r11155 - in trunk/subversion: clients/cmdline include libsvn_client libsvn_ra_dav libsvn_ra_local libsvn_ra_svn libsvn_repos mod_dav_svn svnserve tests/clients/cmdline/getopt_tests_data]
From: Julian Foad <julianfoad_at_btopenworld.com>
Date: 2004-10-02 00:17:16 CEST
OK, I don't want to force the issue, given that we already have 'unsigned' in other APIs, but to continue the thread...
Greg Hudson wrote:
Yes, indeed they do or can. In my first example, I mentioned in a comment that they can; I didn't mention it for the second example, which I suppose was a bit misleading.
It's not clear whether you are just picking me up on my sloppiness or whether you are implying that I'm wrong in asserting that 'unsigned' is far less useful than 'const'. I maintain that the existence of such warnings (only when enabled or when using certain compilers) provides a distinctly lower class of safety than the errors caused by attempting to violate 'const'. (There is another big difference in that 'const' errors apply only to the user of the 'const' pointer, whereas 'unsigned' mismatch warnings apply to both the user and the provider of the value, but I don't think that is very relevant to the discussion.)
The book "Large-Scale C++ Software Design" by John Lakos is _very_ good on both large-scale design issues and small-scale issues, many of which apply to C as well as C++, and he gives level-headed advice on appropriate use of 'unsigned' and 'short' especially in interfaces but also in implementation code. His points are, briefly:
"Guideline: Avoid using 'unsigned' in the interface; use 'int' instead."
Not trying to argue for the sake of it, just trying to advocate goodness.
- Julian
---------------------------------------------------------------------
|
This is an archived mail posted to the Subversion Dev mailing list.
This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.