Wednesday, November 27, 2019

Man or boy test

begin real procedure A(k, x1, x2, x3, x4, x5); value k; integer k; real x1, x2, x3, x4, x5; begin real procedure B; begin k := k - 1; B := A := A(k, B, x1, x2, x3, x4) end; if k  0 then A := x4 + x5 else B end outreal(1,A(10, 1, -1, -1, 1, 0)) end 

There are three Algol features used in this program that can be difficult to implement properly in a compiler:

These things are however not what the test is about; they're merely prerequisites for the test to at all be meaningful. What the test is about is whether the different references to B resolve to the correct instance of B — one that has access to the same A-local symbols as the B that created the reference. A "boy" compiler might for example instead compile the program so that B always accesses the topmost A call frame.



from Hacker News https://ift.tt/2xhJzZ3

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.