Live data from Hacker News

There is no 'printf'

netmeister.org

1–10 of 158 posts

Re: There is no 'printf'

#2
Huh, this is pretty great; I've always fussily used fputs() when I'm just printing static strings, and apparently I don't need to bother, since the compiler will just do it for me.

Re: There is no 'printf'

#5
This is a bit like saying there is no '+';

Because if you put in

    return 1+2+3;

And look at the assembly code, you will see that the compiler generated something like

    return 6;

The compiler is allowed to take advantage of the standard to substitute in more efficient code that does the same thing.

IIRC, for C++, it would actually be ok if std::vector was implemented completely as a compiler intrinsic with no actual header file. (No compiler I am aware of actually does it that way).

Re: There is no 'printf'

#8

This is a bit like saying there is no '+'; Because if you put in return 1+2+3; And look at the assembly code, you will see that the compiler generated something like return 6; The compiler is allowed to take advantage of the standard to substitute in more efficient code that does the same thing. IIRC, for C++, it would actually be ok if std::vector was implemented completely as a compiler intrinsic with no actual hea…

Is there more info to this, I remember this from Commmon Lisp (but details evade me) that the compiler can take benefit of certain specific functions and rely on them being... "open coded" - e.g. it can produce more efficient code by replacing these with something more suitable... http://www.sbcl.org/manual/#Open-Coding-and-Inline-Expansion

https://www.thecodingforums.com/threads/what-is-the-meaning-...

Re: There is no 'printf'

#10

This is a bit like saying there is no '+'; Because if you put in return 1+2+3; And look at the assembly code, you will see that the compiler generated something like return 6; The compiler is allowed to take advantage of the standard to substitute in more efficient code that does the same thing. IIRC, for C++, it would actually be ok if std::vector was implemented completely as a compiler intrinsic with no actual hea…

> more efficient code that does the same thing

In this case, it produces a different result.

Post reply on HN