From: Bronek Kozicki (brok_at_[hidden])
Date: 2006-07-05 18:37:51
Peter Dimov wrote:
> You can (and should) use the same scoping mechanism with strings. Every C++
> type has a string representation. Instead of class N::X, you can use "N::X"
> or the more natural "N.X".
> If you use the same "N.X" string for two distinct purposes, there will be a
> problem; but you can also use the same N::X type for two different purposes,
> and the compiler will not warn. Strings require a bit more discipline, but
> not much.
you are correct, but pls. note that strings provide these benefits only when
used as literals, when compiler cannot be used to enforce discipline. I
believe that in many larger project (where many developers are working on
single sourcetree and names are referred from many files) this is often
non-acceptable and some means to organize names will be needed. Devising such
means for strings is (at least) troublesome, while for tags it is
straightforward. Tags naturally suit to source code organization. How exactly
these tags should be organized is separate issue - I think that they should
not belong to exception hierarchy (nor their header files) but form separate
utility (header or set of headers) providing specific pieces of information
about program state. I'd also guess that such header(s) will contain other
entities (helper functions or classes) specific to given piece of information
about program state.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk