Man or boy test

From Wikipedia, the free encyclopedia

The man or boy test was proposed by computer scientist Donald Knuth as a means of evaluating implementations of the ALGOL programming language. The aim of the test was to separate compilers that correctly implemented scoping and call by name (the "men") from those that did not (the "boys").

[edit] Example

   begin
     real procedure A (k, x1, x2, x3, x4, x5);
     value k; integer k;
     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 (A (10, 1, -1, -1, 1, 0));
   end;
   

This creates a tree of B call frames that refer to each other and to the containing A call frames, each of which has its own copy of k that changes every time the associated B is called. Trying to work it through on paper is probably fruitless, but the correct answer is −67.

[edit] See also

[edit] External link