{ test of @ with both this and identifier
 
}

$c+
module test19_1 
private
	typedefinition integer int;
	
	typedefinition tuple [int val, procedure f()] innerOne;
	
	typedefinition tuple [int first, int second, procedure m()] innerTwo;
	
	procedure innerTwo@m
	begin
		write "done";
	end;
	
	tuple [int f1, int f2, innerOne f3, innerTwo f4, procedure g()] x; 

	procedure x@g
	begin
		write this@f1;
		this@f3!f();
		this@f4!m();
	end;

	procedure innerOne@f 
		typedefinition tuple [int f1, procedure h()] innerTwo;
		typedefinition tuple [int f1, innerTwo f2, procedure m()] innerOne;
		tuple [int f1, innerOne f2, procedure k()] y;
		
		procedure innerOne@m
		begin
			this@f2!h();
		end;
	
		procedure innerTwo@h
			tuple [int val, procedure p()] z;
	
			procedure z@p			
			begin
				y@f1 := y@f2@f2@f1;
				write y@f1 - 1;
				return;  { The following are unchecked recursions} 
				y @ f2 @ f2 ! h();            {<---- check -----}
				z ! p();             		{<---- check -----}
				this ! p();             	{<---- check -----}
			end;
		begin
			y := [5, [6, [3] ] ];
			z!p();
		end;
		
		procedure y@k
		begin
			this@f2!m();
		end;
	begin {f}
		y!k();
		write this@val;
	end;
begin
  x := [1, 2, [3], [4, 5] ];
  
  x!g();
  
end. { output: 1 2 3 done}

