Jensens Device

An early use of CallByName, see the following AlgolLanguage code:

   begin integer i;

real procedure sum(i, lo, hi, term); value lo, hi; integer i, lo, hi; real term; comment term is passed by-name; begin real temp; temp := 0; for i := lo step 1 until hi do temp := temp + term; sum := temp end;

print( sum(i, 1, 100, 1/i), 6, 3 ) end

The answer is 5.187378...

Apparently DonaldKnuth thought it was a good idea, and wrote the ManOrBoy test to determine which compilers could handle it correctly.


EditText of this page (last edited October 31, 2000) or FindPage with title or text search