4 ms·
Rust has this with its macro_rules! macros. It's not as good of a solution as it initially seems.
by wizzwizz4 5y ago
Rust has this with its macro_rules! macros. It's not as good of a solution as it initially seems.
- xg15 5y agoInteresting to know. What were the issues?
- wizzwizz4 5y agoMostly the syntax is bad, I think. Also, exposing the AST like this means implementation details about the parser are now locked in.
- xg15 5y agoI can understand the syntax bit. For that feature it's really important the syntax is accessible. (I have no illusions how bad my syntax above was. I just threw it together to illustrate the point) Disagreed on the AST though. I think a lot of problems can be solved if a programming language has a well-defined publicly available grammar and if access to its AST is easy. As an example, a lot of innovation in modern IDEs comes from the IDE's ability to actually parse the code files and build object graphs. Knowing details about the AST is necessary for that.
- wizzwizz4 5y agoKnowing details about the grammar is necessary for that. Rust's macro_rules! (and, to a lesser extent, your syntax) exposes implementation details about the compiler as parts of the standard, so it's difficult to use (e.g.) a different architecture of parser.
- xg15 5y ago> and, to a lesser extent, your syntax That was a fantasy syntax I just made up. How can I expose implementation details of a compiler that doesn't exist?