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

Sounds like what Rust needs is compile macros [1]. That way, printf can still be a function, but it would be optimized at compile time if the formatting string is constant.

[1] https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node101.html



Compile macros wouldn't be sufficient for Rust's println! because the type signature (even the number of arguments) depends on the format string. The format string has to be constant and has to be interpreted at compile time so that the variables being printed can be type-checked.




Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

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

Search: