return function(z,T,P)for T,P in pairs(T)do if z[T]==nil then error("\068\105\100 \110\111\116 \112\114\111\118\105\100\101 \114\101\113\117\105\114\101\100 \097\114\103\117\109\101\110\116 "..T)end end if P then for T,P in pairs(P)do if z[T]==nil then z[T]=P end end end for z in pairs(z)do if T[z]==nil and(not P or P[z]==nil)then error("\080\114\111\118\105\100\101\100 \105\110\118\097\108\105\100 \097\114\103\117\109\101\110\116 "..z)end end end

return function(arguments, requiredArguments, optionalArguments)
	for key, _ in pairs(requiredArguments) do
		if arguments[key] == nil then
			error("Did not provide required argument " .. key)
		end
	end

	if optionalArguments then
		for key, defaultValue in pairs(optionalArguments) do
			if arguments[key] == nil then
				arguments[key] = defaultValue
			end
		end
	end

	for key in pairs(arguments) do
		if requiredArguments[key] == nil and ((not optionalArguments) or optionalArguments[key] == nil) then
			error("Provided invalid argument " .. key)
		end
	end
end
