ilovepi wrote:

> Nodes are write once by the parser and read only after that, same as clang 
> ast. why would mutation methods make sense here?

The parser typically uses the AstNode's methods to construct the tree. The same 
way you'd typically construct a link list in C++ by giving the nodes methods to 
update their internal state. In clang, AST types are not just simple C-style 
structs. They are  complex classes that support a number of operations 
including provide rich introspection APIs.  Mustache is quite a bit simpler, 
but even then the nodes supply operations relevant to their use: 
https://github.com/llvm/llvm-project/blob/4c203981fc40698bca926c9b41c98574648d537f/llvm/lib/Support/Mustache.cpp#L183

Lets ask a different question: what its going to be like to debug your data 
structure if you can't dump its contents or examine it easily? The way things 
stand, every user of the Node type has to know how to poke and prod its 
internals, and can change its state correctly. 

Dumb POD structs that just provide convenient bundles of data are fine to use 
in the right spots, but LLVM as a whole is a pretty opinionated C++ codebase 
that prefers strong types and classes with limited amounts of inheritance. 
clang-doc is generally quite a bit looser about this kind of thing than other 
parts of the project, but the MD parser is not intended to stay private to 
clang-doc, and as mentioned integration into clang will come with a very high 
bar for quality.

https://github.com/llvm/llvm-project/pull/205609
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to