2 ms·
Have you actually studied the go compiler implementation and found that comments are preserved across all stages or are you just speculating? I can imagine a d
by sunnyps 11y ago
Have you actually studied the go compiler implementation and found that comments are preserved across all stages or are you just speculating?
I can imagine a design that works where only the lexer keeps track of comments (with locations) and the remaining stages do not. In fact using comments to generate code is not all that different from using comments to generate documentation (like doxygen) and that shouldn't require comments at the AST stage.
- brandonbloom 11y ago> Have you actually studied the go compiler implementation ... Yes. Though it's worth mentioning that they use the same AST infrastructure for `go format` and `go fix`. That means they need to track comments anyway. However, those use cases don't necessarily have the same requirements for accurately matching comments to semantically meaningful nodes. > using comments to generate documentation (like doxygen) 1) I don't really believe in javadoc or doxygen really. 2) Even if I did, I'd prefer actually (and similarly lightweight!) metadata notation. 3) Also consider runtime documentation support. eg: https://clojuredocs.org/clojure.repl/doc https://clojuredocs.org/clojure.repl/doc and https://clojuredocs.org/clojure.repl/source https://clojuredocs.org/clojure.repl/source