3 ms·
Does it extend to C or to Nim itself? Rust macros extend to Rust, and as an input it can receive any valid tokens (the only condition being to have all opening
by DiThi 9y ago
Does it extend to C or to Nim itself? Rust macros extend to Rust, and as an input it can receive any valid tokens (the only condition being to have all opening and closing () {} [] match correctly).
Rust procedural macros are one of the reasons I started using Rust.
- dom96 9y agoIt extends to Nim, and macros can also receive any valid Nim token. Alternatively you can also pass a string literal and parse it in your macro. Nim's metaprogramming support is quite extensive, possibly even more so than Rust's. If this is something that interests you then you should check it out. As an example of what's possible: async await in Nim is implemented entirely via a macro[1], the `=>` operator for closures is also implemented as a macro[2]. 1 - Example chat app client using async await: https://github.com/dom96/nim-in-action-code/blob/master/Chapter3/ChatApp/src/client.nim#L4 https://github.com/dom96/nim-in-action-code/blob/master/Chap... 2 - Implementation of `=>`: https://github.com/nim-lang/Nim/blob/devel/lib/pure/future.nim#L49 https://github.com/nim-lang/Nim/blob/devel/lib/pure/future.n...
- DiThi 9y agoThat's good to know, thanks. In many ways Nim resembles my ideal language that I wanted to make time ago. Rust is still above on my list, though. May give Nim a try if I get too frustrated with Rust.