Boost logo

Boost Users :

Subject: Re: [Boost-users] Why something like #ifndef BOOST_MPI_HPP is alwayscapitalized?
From: Scott McMurray (me22.ca+boost_at_[hidden])
Date: 2008-09-19 18:04:07


On Fri, Sep 19, 2008 at 16:30, Peng Yu <pengyu.ut_at_[hidden]> wrote:
> I'm wondering how you would handle the following case.
>
> Suppose I have a set of mathematical formulas that has both bigger case and
> lower case variables (such as both 'X' and 'x'). This situation is pretty
> common. In order to implement them in C++, I could either write bigger cases
> as well as lower cases in C++, which is not in consistence with the
> convention that you mention. Or I have to convert bigger cases to lower
> cases, which is also not easy to read, as it is different from the original
> mathematical form.
>
> Which approach would you prefer? I would prefer the former one. Therefore,
> the convention is not followed.
>

It's generally a very bad idea for readability to have names that
differ only in case. The situation you describe would one one of the
few exceptions, but even then it'd be reasonable only for local
variables in a very small scope.

You always have the option of upper_x and lower_x or big_x and
little_x, which are perfectly clear, if more verbose.

For headers, though, you can't have 2 headers whose names differ only
in case on windows (and quite plausibly other filesystems), so the
situation will never arise in portable code. Thus, there's no issue
with using all-uppercase for the include guard macro.

~ Scott


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net