Search

The Online Encyclopedia and Dictionary

 
     
 

Encyclopedia

Dictionary

Quotes

 

Man or boy test

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").

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;
   end;
   outreal(A(10, 1, -1, -1, 1, 0));

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.

External links

Last updated: 10-12-2005 12:42:32
The contents of this article are licensed from Wikipedia.org under the GNU Free Documentation License. How to see transparent copy