Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Rust macros have no access to types at all. Types are essential for any but the most trivial metaprogramming.


If you consider the scope of metaprogramming to include both macros and traits (and I do), then this is seriously understating the case. Rust's type system has a Prolog-like core and is Turing complete, so is quite expressive in able hands. A great example of the two features working together is serde, which automatically derives serialization and deserialization code (with custom overridable behavior such as defaults) for a very wide range of types. It's also something like 20-50x faster than Swift's Codable based implementation of JSON.


I guess I do, too, now. It has got more powerful since I last looked.


Can you give a specific example of this?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: