Re: [PATCH for Dlang support] d: add support for lookahead correction

"H. S. Teoh" <[email protected]>
Newsgroups gmane.comp.parsers.bison.patches
Message-ID <[email protected]>
On Wed, Nov 18, 2020 at 08:46:22AM +0100, Akim Demaille wrote:
> > Le 17 nov. 2020 à 19:09, Adela Vais <[email protected]> a écrit :
> > 
> > When using lookahead correction, the method
> > YYParser.Context.getExpectedTokens is not annotated with const,
> > because the method calls yylacCheck, which is not const.
> 
> It is logically const though.  It's only because its auxiliary stack
> is stored in the parser to avoid repeated construction/destruction,
> that it needs to "alter the parser".
[[...]

D unfortunately does not have "logical const". It has "physical const"
which is mechanically enforced by the compiler.  Furthermore, const is
"infectious" (transitive): once a reference is marked const, everything
it refers to is also const, as far as can be seen via that reference.  A
const reference can refer to a mutable object, but you cannot modify the
object through that reference, it can only be mutable through a mutable
reference.


T

-- 
If you think you are too small to make a difference, try sleeping in a closed room with a mosquito. -- Jan van Steenbergen
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.