Cool. On the other hand, projects like these suggest to me that Macro systems like Rust's are a bit too powerful. Not that I know how to make it just enough less powerful.
Show HN: A Rust macro that parses Java-like syntax and runs it as a Rust program
11–20 of 35 posts
Re: Show HN: A Rust macro that parses Java-like syntax and runs it as a Rust program
#12How well do LSP implementations cope with complex macros like this?
Re: Show HN: A Rust macro that parses Java-like syntax and runs it as a Rust program
#13There are a few things that are annoying about writing macros* (in particular when I last checked there was no way to break the hygiene which is something that is occasionally useful for eg making lots of functions that follow a similar template) in Rust but in general I think they strike a really nice balance for a language with complex syntax: 1. Macros only happen in certain points and don’t need to be known to be…
while ($($cond:tt)*) {
You'll actually match both while (true) {
and while (5 * (2 + 3)) {
. It counts the parenthesis :DRe: Show HN: A Rust macro that parses Java-like syntax and runs it as a Rust program
#14There are a few things that are annoying about writing macros* (in particular when I last checked there was no way to break the hygiene which is something that is occasionally useful for eg making lots of functions that follow a similar template) in Rust but in general I think they strike a really nice balance for a language with complex syntax: 1. Macros only happen in certain points and don’t need to be known to be…
I gotta say what I really like about macros are that ( and )s are matched. If you say: while ($($cond:tt)*) { You'll actually match both while (true) { and while (5 * (2 + 3)) { . It counts the parenthesis :D
MAC((here, have one argument), and then this second one)Re: Show HN: A Rust macro that parses Java-like syntax and runs it as a Rust program
#15There are a few things that are annoying about writing macros* (in particular when I last checked there was no way to break the hygiene which is something that is occasionally useful for eg making lots of functions that follow a similar template) in Rust but in general I think they strike a really nice balance for a language with complex syntax: 1. Macros only happen in certain points and don’t need to be known to be…
I gotta say what I really like about macros are that ( and )s are matched. If you say: while ($($cond:tt)*) { You'll actually match both while (true) { and while (5 * (2 + 3)) { . It counts the parenthesis :D
foo!((x))
As foo! ( { ( x ) } )
Or foo! ( { ( x } ) )
With {} representing the argument to the macro.Re: Show HN: A Rust macro that parses Java-like syntax and runs it as a Rust program
#16Cool. On the other hand, projects like these suggest to me that Macro systems like Rust's are a bit too powerful. Not that I know how to make it just enough less powerful.
Re: Show HN: A Rust macro that parses Java-like syntax and runs it as a Rust program
#17How well do LSP implementations cope with complex macros like this?
I wrote a rather large macro to auto-generate a Java-Ops parser. The I spent the next 4 days re-writing it so I didn’t have to give the Rust compiler 4GiB of stack just to compile.
Deeply recursive structures (boardering on 1mil+ recursion depth gets rough)
Re: Show HN: A Rust macro that parses Java-like syntax and runs it as a Rust program
#18Re: Show HN: A Rust macro that parses Java-like syntax and runs it as a Rust program
#19Would it be possible to write a compiler from Java to Rust? C# to rust? The goal then would be to get fast(er) execution times.
There are probably research experiments that have involved ahead of time compilation, but if they had succeeded then I expect most people would have used them.
GraalVM looks very promising.
Re: Show HN: A Rust macro that parses Java-like syntax and runs it as a Rust program
#20There are a few things that are annoying about writing macros* (in particular when I last checked there was no way to break the hygiene which is something that is occasionally useful for eg making lots of functions that follow a similar template) in Rust but in general I think they strike a really nice balance for a language with complex syntax: 1. Macros only happen in certain points and don’t need to be known to be…