Created
June 13, 2014 21:44
-
-
Save nefftd/07ee9237579956c24871 to your computer and use it in GitHub Desktop.
argcheck (moonscript)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
do | |
checktypelist = (t,a1,...) -> | |
t == a1 or checktypelist t,... if a1 ~= nil | |
export argcheck = (val,argn,...) -> | |
return if checktypelist type(val),... | |
types = '/'\join tostringall ... | |
fname = debug.getinfo(2,'n').name or 'unknown' | |
error "bad argument ##{tonumber(argn) or '?'} to '#{fname}' (#{types} expected, got #{type val})",3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment