help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

filename() field should be const std::string* not std::string*


From: Martin Blais
Subject: filename() field should be const std::string* not std::string*
Date: Sun, 24 May 2020 10:56:04 -0400

Dear grammar-generators,
I'm setting up my %initial-action directive this morning (so much fun) and
I can't help notice that the C++ location() and position() constructors and
initializers accept an "std::string*" and not a "const std::string*",
despite not modifying their value anywhere. The docs on the "position"
class say:

Instance Variable of position: std::string* file
  The name of the file. It will always be handled as a pointer, the parser
will never duplicate nor deallocate it. As an experimental feature you may
change it to ‘type*’ using ‘%define filename_type "type"’.

The generated parser doesn't seem to modify it.
This forces by driver object to cast away what should otherwise be a
comforting const access.
I can "fix" this by using
%define filename_type "const std::string"

Is there any reason not to make the default const?

Thank you,


reply via email to

[Prev in Thread] Current Thread [Next in Thread]