function u=construct(s,sizes_in)

	nin=nargin(s.base);

	u=construct(s.base,s.sizes_in(1:nin));
	u.sizes_out = [u.sizes_out]; % !!! this is wrong. need better type system
	u.process = mkproc(u.process,nin,nargout(s.base));
end

function f=mkproc(g,nin,nout)
	empty={{}};
	f=@proc;
	if nin==1 && nout==1, f=@proc_11;
	elseif nin==1 && nout==0, f=@proc_10; 
	else, f=@proc_nn; end

	function proc_10(x1), 
		if ~isempty(x1), g(x1{1}); end; 
	end
	function y1=proc_11(x1,x), if isempty(x1), y1={}; else y1={g(x1{1})}; end; end

	function varargout=proc_nn(varargin)
		if any(cellfun(@isempty,varargin)), varargout=repmat(empty,1,nout);
		else
			ins=cellfun(@unbox,varargin(1:nin));
			[outs{1:nout}]=g(ins{:});
			varargout=cellfun(@box,outs);
		end
	end
	function x=unbox(y), x=y{1}; end
	function y=box(x), y={x}; end
end

