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

Backward compatibility. Your example would impose additional constraints on the %d specifier that would likely break existing code. What if you want an int immediately followed by literal ”64”?


Oops, I typoed. I said 'new *printf functions'; the example was supposed to be 'printf2("int64: %d64", x)'


I see! That would make more sense, but I still think the inttypes.h macros are a sufficient solution. Implementers and standards influencing users probably aren't too keen on another formatting language when you can implement it as macros that only take another few characters to use.

    printf2("int64: %d64", x);
for example isn't significantly shorter than

    printf("int64: %" PRId64, x);
Perhaps it's easier to read, but when you have to support both, and you're more likely to run into the latter than the former anyway, I think it just adds cognitive overhead to have to consider which formatting language is being used.




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

Search: