On Wednesday, 17 June 2020 at 11:50:27 UTC, Per Nordlöw wrote:
Should a range-compliant aggregate type realizing a parser be
encoded as a struct or class? In dmd `Lexer` and `Parser` are
both classes.
In general how should I reason about whether an aggregate type
should be encoded as a struct or class?
You have the example of libdparse that shows that using a class
can be a good idea [1] [2].
For DCD, the parser overrides a few thing because otherwise
completion does not work properly or has scope issues. But TBH
there's not many reasons to use a class otherwise.
[1]
https://github.com/dlang-community/dsymbol/blob/master/src/dsymbol/conversion/package.d#L102
[2]
https://github.com/dlang-community/dsymbol/blob/master/src/dsymbol/conversion/package.d#L138