Pointers in ROOT, GEANT4 and other disgraced frameworksTrail Index | References and Pointers | Pointers in Root and Geant4 Rootin ROOT, you are usually forced to use pointers when you construct ROOT object, even when it would not make any sense at all. This is because ROOT objects are usually registered with some kind of non-standard internal memory handler, a concept which is the unfortunate legacy of the origins of ROOT in the Fortran77 code of CERNLIB/PAW. So, if you try to delete, for example, a histogram ( This is against all rules of good OO programming, and against common sense as well. But you will have to live with it. ROOT developers try to justify this by the convenience provided by
the "global dictionary" of all objects that is maintained in this way;
but it's no excuse. When something like that is used, the objects should
not be allowed a Geant4In all fairness, GEANT4 suffers from the same kind of problems.
For example, objects are allocated in the This is exceedingly confusing for the newbies, who have just been told that all allocated memory must be accounted for, and deallocated! They will randomly be punished with incomprehensible segfaults for deallocating objects which they have allocated, and, in a typical Pavlovian reaction, will just stop trying to do it even when they should. This inconsistency could be easily resolved by changing those PhysVolume* uselessPointer = new PhysVolume(params); into PhysVolume& tempRef = createPhysVolume(params); allowing the user to clearly distinguish between
objects managed by GEANT and those that she actually has
to manage on his own (like an The present status promotes the sloppiness and bad style which are already all too common amongst physicists, who are not well trained in Computer Science. < Dynamic Memory | Trail Index | Objects 2 > |