[M3devel] m3cc static chain stuff

hendrik at topoi.pooq.com hendrik at topoi.pooq.com
Sat May 29 10:43:35 CEST 2010


On Sat, May 29, 2010 at 03:10:46AM +0000, Jay K wrote:
> 
> Ok ok let me explain my "real" questions.
>  
>  
>  
>  - Can someone show me an example (or add a test case) that demonstrates the "full" functionality of nested functions, pointers to them, comparing said pointers for equality, and recursion?
>  

Here's the classic test, in Algol 60:

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;

reference:

http://en.wikipedia.org/wiki/Man_or_boy_test

See also:

http://www.rosettacode.org/wiki/Man_or_boy_test

This page has a version which simulates closures in C.

-- hendrik



More information about the M3devel mailing list