Should a parser type be a struct or class?
Stefan Koch
uplink.coder at googlemail.com
Wed Jun 17 14:24:01 UTC 2020
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?
I would say a struct.
Parser in dmd does even inherit from Lexer.
It seems to be a quirky design.
Especially for multi-threaded parsing you might want to have more
control over memory layout than classes usually give you.
More information about the Digitalmars-d-learn
mailing list