News for hackers. Stuff that matters.
Re:Literate programming: Knuth is doing it wrong (2014) by int_19h on Monday January 13, 2025 @06:53PM (#42691249)
The problem with functions is that when you see something like this:

   F(X);
there may be implicit conversions happening to X here depending on its type, and, crucially, the declared type of the argument - e.g. Integer to Real. This would be a separate function call in many cases, so it's not just a single address to patch - indeed, you don't even know the size of the code that will need to be inserted in advance.
Re:Literate programming: Knuth is doing it wrong (2014) by Joker_vD on Tuesday January 14, 2025 @01:34AM (#42694406)
Yes, and the way that e.g. C famously handles it is that it treats it as X being implicitly int, if it's an integral expression that produces something shorter than long, and a double, if X is a floating-point-valued expression, and whatever happens to structs when invoking implicitly-declared functions.

This, again, can be checked for the correctness at the end of the translation of a particular compilation unit, C just decided to not bother with this at all and leave it to the linker to figure out (even though it started its life as a language with 2-and-a-half passes compiler), and Pascal and its descendants decided to require either forward declarations, or using function pointers. I personally think that e.g.

    var F: proc(whatever): whatever;

    proc G() begin
        ... F(whatever); ...
    end G;

    proc F0(whatever): whatever begin
        ... G(); ...
    end F0;

    begin
        F := F0;
    end module.
is a needless pessimization but e.g. Oberon does it this way.