<commit_before>% Some tests. feed the first paragraph and then the 3 at the end of the file.
declare
[Comp] = {Module.link ['lib/component.ozf']}
% NewQueue will be totatly hide for the user
fun {NewQueue}
   Given GivePort = {NewPort Given}
   Taken TakePort = {NewPort Taken}
   proc {Match Xs Ys}
      case Xs # Ys
      of (X|Xr) # (Y|Yr) then
	 X=Y
	 {Match Xr Yr}
      [] nil # nil then skip
      end
   end
in
   thread {Match Given Taken} end
   queue(put: proc{$ X} {Send GivePort X} end
	 get: proc{$ X} {Send TakePort X} end)
end
%This state of a component had 1 input port, and simply browse the IP
Display = component(inPorts:'in'(input:port(q:{NewQueue} % The buffer of the port, will be hidden for the user
					   p:proc {$ IP Out Var} {Browse 1#IP} end % The procedure to deal with the IP
					   s:nil % Use for synchronization, will be hidden for the user
					  )
			       ) % A record with all the input ports (can be simple or array)
		    outPorts:out % A record with all the output ports (no here)
		    procs:procs  % A record with all the independant procedure (no here)
		    var:var      % The shared variables between the procedures (unique assignement)
		   )
C = {Comp.new} % create a componenet
{C changeState(Display)} % Load the state that we just create
% Nearly the same, just to distinguish the two
Display2 = component(inPorts:'in'(input:port(q:{NewQueue}
					   p:proc {$ IP Out Var} {Browse 2#IP} end
					   s:nil
					  )
			       )
		    outPorts:out
		    procs:procs
		    var:var
		   )
C2 = {Comp.new}
{C2 changeState(Display2)}
% This component do :  x*y + sum(z). There is 3 shared variable between the procedure x, y and z. The input ports load these values, and the proc in procs make the calcul.
Mul = component(inPorts:'in'(x:port(q:{NewQueue}
				    p:proc{$ IP Out Var} {Browse begin} Var.x = IP end
				    s:nil)
			     y:port(q:{NewQueue}
				    p:proc{$ IP Out Var} Var.y = IP end
				    s:nil)
			     z:arrayPort(qs:queues()
					 p:proc{$ IPs Out Var} Var.z = {FoldR IPs fun{$ E Acc} E+Acc end 0} end
					 s:[nil])
			    )
		outPorts:out(output:nil)
		procs:procs(proc {$ Out Var}
			       {Browse beginOut}
			       {Wait Var.x} % Wait is use to see if the Var is set by another proc
			       {Wait Var.y}
			       {Wait Var.z}
			       {Out.output Var.z + Var.x*Var.y}
			    end)
		var:var(x:_ y:_ z:_)
	       )
D = {Comp.new}
{D changeState(Mul)}
{D addinArrayPort(z)} % Say the the array input port that we need two entries
{D addinArrayPort(z)}
{D bind(output C input)} % Bind the component between them
{D bind(output C2 input)}

%First test
{D send(x 7)}
{D send(y 1)}
{D send(z#1 1)}
{D send(z#2 2)}

%Second test. A procedure is change while the sync is not ready, so it has no effect
{D send(x 7)}
{D send(y 1)}
{D changeProcPort(x proc {$ IP Out Var} {Browse begin2} Var.x = 2*IP end)}
{D send(z#1 1)}
{D send(z#2 2)}

%Third test. The new procedure is executed!
{D send(x 7)}
{D send(y 1)}
{D send(z#1 1)}
{D send(z#2 2)}
<commit_msg>another test<commit_after>% Some tests. feed the first paragraph and then the 3 at the end of the file.
declare
[Comp] = {Module.link ['lib/component.ozf']}
% NewQueue will be totatly hide for the user
fun {NewQueue}
   Given GivePort = {NewPort Given}
   Taken TakePort = {NewPort Taken}
   proc {Match Xs Ys}
      case Xs # Ys
      of (X|Xr) # (Y|Yr) then
	 X=Y
	 {Match Xr Yr}
      [] nil # nil then skip
      end
   end
in
   thread {Match Given Taken} end
   queue(put: proc{$ X} {Send GivePort X} end
	 get: proc{$ X} {Send TakePort X} end)
end
%This state of a component had 1 input port, and simply browse the IP
Display = component(inPorts:'in'(input:port(q:{NewQueue} % The buffer of the port, will be hidden for the user
					   p:proc {$ IP Out Var} {Browse 1#IP} end % The procedure to deal with the IP
					   s:nil % Use for synchronization, will be hidden for the user
					  )
			       ) % A record with all the input ports (can be simple or array)
		    outPorts:out % A record with all the output ports (no here)
		    procs:procs  % A record with all the independant procedure (no here)
		    var:var      % The shared variables between the procedures (unique assignement)
		   )
C = {Comp.new} % create a componenet
{C changeState(Display)} % Load the state that we just create
% Nearly the same, just to distinguish the two
Display2 = component(inPorts:'in'(input:port(q:{NewQueue}
					   p:proc {$ IP Out Var} {Browse 2#IP} end
					   s:nil
					  )
			       )
		    outPorts:out
		    procs:procs
		    var:var
		   )
C2 = {Comp.new}
{C2 changeState(Display2)}
% This component do :  x*y + sum(z). There is 3 shared variable between the procedure x, y and z. The input ports load these values, and the proc in procs make the calcul.
Mul = component(inPorts:'in'(x:port(q:{NewQueue}
				    p:proc{$ IP Out Var} {Browse begin} Var.x = IP end
				    s:nil)
			     y:port(q:{NewQueue}
				    p:proc{$ IP Out Var} Var.y = IP end
				    s:nil)
			     z:arrayPort(qs:queues()
					 p:proc{$ IPs Out Var} Var.z = {FoldR IPs fun{$ E Acc} E+Acc end 0} end
					 s:[nil])
			    )
		outPorts:out(output:nil)
		procs:procs(proc {$ Out Var}
			       {Browse beginOut}
			       {Wait Var.x} % Wait is use to see if the Var is set by another proc
			       {Wait Var.y}
			       {Wait Var.z}
			       {Out.output Var.z + Var.x*Var.y}
			    end)
		var:var(x:_ y:_ z:_)
	       )
D = {Comp.new}
{D changeState(Mul)}
{D addinArrayPort(z)} % Say the the array input port that we need two entries
{D addinArrayPort(z)}
{D bind(output C input)} % Bind the component between them
{D bind(output C2 input)}

%First test
{D send(x 7)}
{D send(y 1)}
{D send(z#1 1)}
{D send(z#2 2)}

%Second test. A procedure is change while the sync is not ready, so it has no effect
{D send(x 7)}
{D send(x 7)}
{D send(y 1)}
{D changeProcPort(x proc {$ IP Out Var} {Browse begin2} Var.x = 2*IP end)}
{D send(z#1 1)}
{D send(z#2 2)}

%Third test. The new procedure is executed!
{D send(y 1)}
{D send(z#1 1)}
{D send(z#2 2)}

{'fraction_non_alphanumeric': 0.11597554931438955, 'fraction_numerical': 0.010242854782752353, 'mean_word_length': 2.7979924717691342, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5722320', 'n_tokens_mistral': 2371, 'n_tokens_neox': 2093, 'n_words': 835}