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

The compiler does not need to implement it with the macros shown. They could use other techniques, so long as it has the same net result of preserving constness of the argument. For example, the macro definitions could easily use a macro that resolves to a magic generic intrinsic (which becomes a call the existing function implementation) that maintains the constness of the argument.

An exponential code size increase even with the example implementation would only happen if people are nesting these functions inside each other. And while that could happen, it would be unusual to nest them very deeply. So for compilers that just want an easy implementation, and don't really care about quality of error messages or maximizing compile speed, the shown approach is probably fine.



Consider applying for YC's Summer 2026 batch! Applications are open till May 4

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

Search: