News for hackers. Stuff that matters.
Re:Implementing a Type-safe printf in Rust by lmm on Friday August 14, 2020 @03:34AM (#24154952)
- Possibility of implementation errors

- A reader can't really reason about what a macro might be doing, since they're immensely powerful.

- Tooling can't necessarily understand macros correctly, for the same reason. E.g. automated refactoring like extracting a repeated expression can't be relied on to work correctly.

Re:Implementing a Type-safe printf in Rust by zaarn on Friday August 14, 2020 @04:09AM (#24155189)
The thing is though that Rust macro's are hygienic; the macro must generate the syntax tree and cannot mangle outside scope. Most rust tooling I've seen handles and understands printf as a macro easily and tooling is improving to be able to fully introspect a macro.
Re:Implementing a Type-safe printf in Rust by methyl on Friday August 14, 2020 @05:16AM (#24155646)
These are downsides of macros in general, but I don't see how they are relevant to a built-in macro from stdlib.
Re:Implementing a Type-safe printf in Rust by lmm on Friday August 14, 2020 @05:29AM (#24155720)
They apply just the same in the standard lib surely? I suppose tooling might be expected to have support for the standard lib, but you're creating a lot more work for tool implementors if there is a large (and presumably evolving) set of "standard" macros. The concern about the reader is definitely still there unless you're expecting every Rust user to memorize which macros are in the standard library.