| Summary: | Request to remove "using" declarations from G4PhysicalConstants.hh and G4SystemOfUnits.hh | ||
|---|---|---|---|
| Product: | Geant4 | Reporter: | jasondet |
| Component: | global/management | Assignee: | Gabriele Cosmo <Gabriele.Cosmo> |
| Status: | RESOLVED WONTFIX | ||
| Severity: | enhancement | ||
| Priority: | P5 | ||
| Version: | 9.4 | ||
| Hardware: | All | ||
| OS: | All | ||
|
Description
jasondet
2011-10-18 05:39:38 CEST
The use of physical constants and units as defined is part of the user's API since the beginning in Geant4, well before namespaces became part of the C++ standard and implemented in all compilers. Therefore, their use in the global namespace -cannot- be easily avoided without imposing massive migration in the user codes. We can try to reduce their use within the internal headers in Geant4, but cannot modify the API at this point in time; G4PhysicalConstants.hh and G4SystemOfUnits.hh are meant to allow users's API compatibility. That's too bad. For the record, I would like to add the following arguments. As a 10+ year user of G4, my experience is that migrating user code is an expected step when upgrading to any new G4 release. For this case, simple remedies could be introduced to ease the migration, e.g. by allowing users to add something like "using namespace Geant4;" at the top of files that need it. A CPP directive could also easily be implemented and set during configuration to keep these variables in the global namespace if a user desires. So I think that with a little effort this change could be implemented in a way that does not require "massive" user migration. As for API compatibility, while this may have been implemented to "allow users' API compatibility" with G4, by putting variables in the global namespace it breaks compatibility with other APIs, making the Geant4 API less compatible and more painful to use. So that point really did not make sense to me. Anyway thank you for considering my suggestion. Perhaps at least keep this in mind for future releases. Sincerely, Jason Detwiler Hi Jason, the current implementation makes sense as long as the original API for physical constants and units is _the_ valid one users should adopt. I perfectly understand your concerns, as this issue has been matter of discussion when namespaces were introduced in CLHEP and was explicitly decided to keep the current API, following the input from the users community (particularly HEP experiments). We may envisage at some point to move to a coherent (and perhaps selectable) use of the namespaces for this, in a way similar to what you suggest, but cannot promise this to happen in a too near future... Cheers, Gabriele |