Plan for removing global state from GCC's internals
Joseph S. Myers
joseph@codesourcery.com
Tue Jul 2 20:25:00 GMT 2013
On Mon, 1 Jul 2013, Aaron Gray wrote:
> I started to do this starting with the C++ parser class'izing it but
> no one was interested.
The C++ parser types such as cp_parser and cp_lexer already do a good job
of avoiding global state.
I am not an expert on good C++ coding practices and don't know to what
extent the objections given in
<http://gcc.gnu.org/ml/gcc-patches/2012-08/msg02019.html> might apply to
any parts of David's proposal. But in David's proposal, conversion to
classes is a means to an end - eliminating global state through passing
implicit "this" pointers - and not an end in itself if the global state
does not exist, or if it can easily be moved inside an existing structure
such as cp_parser or gcc_options rather than needing to go inside some new
class.
(I would add that the optimizations for singletons are also a means to an
end. In cases where we might reasonably expect multiple instances of
something inside a universe, we should be perfectly willing not to use
those optimizations and always to pass pointers around, whether explicitly
or implicitly. And we should expect that as interfaces get cleaned up in
future and are adapted to different ways people may wish to use GCC in a
library, cases that start off by using the singleton optimizations are
likely to have them removed.)
--
Joseph S. Myers
joseph@codesourcery.com
More information about the Gcc
mailing list