3 ms·
Using this as an example of Rust's verbosity is uninformed. The reason that syntax extensions are undocumented is because they are highly unstable and not inten
by kibwen 12y ago
Using this as an example of Rust's verbosity is uninformed. The reason that syntax extensions are undocumented is because they are highly unstable and not intended for end-user consumption (users of Rust 1.0 will not be able to create syntax extensions). They operate by reaching deep into the guts of the compiler and directly playing with APIs that have been designed for consumption by compiler authors. That they are exposed at all in the unstable branch of Rust is because Rust is a language that prefers to shove as much logic out of the compiler and into the stdlib as it can, and syntax extensions are one mechanism by which this is currently achieved.
Furthermore, your example is misguided. Syntax extensions are not for trivial rewriting, that's the purpose of macros. Syntax extensions are for doing things like expanding a regex into a finite state machine at compile-time, or providing custom extensions to Rust's type system. In terms of tools, they are a 40-foot industrial lathe which can do anything, but is overkill for the vast majority of tasks.
- progman 12y ago> Syntax extensions are not for trivial rewriting, that's the purpose of macros. Syntax extensions are for doing things like expanding a regex into a finite state machine at compile-time. Nim provides templates and macros for that. Templates are for rewriting while macros can create arbitrary AST nodes. http://blog.ldlework.com/2015/05/01/a-cursory-look-at-meta-programming-in-nim/ http://blog.ldlework.com/2015/05/01/a-cursory-look-at-meta-p...