function u=construct(s,sizes_in)
	u=mkunit(s);
	fn=s.fn(sizes_in);
	if isempty(s.sizefn) 
		u.sizes_out=guess_sizes(fn,sizes_in,nargout(s));
	else 
		u.sizes_out=s.sizefn(sizes_in);
	end
	u.process=mkproc(fn,nargin(s),nargout(s));

end

function f=mkproc(fn,nin,nout);
	if     nout==0, f = @proc_n0;
	elseif nin==0,  f = @proc_0n;
	elseif nin==1 && nout==1, f=@proc_11;
	else f=@proc_nn; end

	function proc_n0(varargin), fn(varargin{1:nin}); end
	function out=proc_11(in), out=fn(in); end
	function varargout=proc_0n, [varargout{1:nout}]=fn(); end
	function varargout=proc_nn(varargin), 
		[varargout{1:nout}]=fn(varargin{1:nin}); 
	end
end

function sz_out=guess_sizes(fn,sz_in,nout)
	ins = map(@zeros,sz_in);
	[outs{1:nout}] = fn(ins{:});
	sz_out = map(@size,outs);
end

