diff --git a/lib/cli.js b/lib/cli.js index b6fb793..7e4ed16 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -5,18 +5,12 @@ var sibilant = require("sibilant"), script = (process.binding("evals"))["Script"], context = script.createContext(); var createContext = (function() { - if (arguments.length > 0) - throw new Error("argument count mismatch: expected no arguments"); - context.initializedQ = true;; (module)["filename"] = (process.cwd() + "/exec");; (context)["module"] = module;; (context)["require"] = require;; return (function() { for (var key in global) (function() { - if (arguments.length > 0) - throw new Error("argument count mismatch: expected no arguments"); - return (context)[key] = (global)[key];; })(); })();; diff --git a/lib/functional.js b/lib/functional.js index 352fb0d..dfd0021 100644 --- a/lib/functional.js +++ b/lib/functional.js @@ -74,9 +74,6 @@ var reject = (function(items, fn) { // items:required fn:required var args = [ items, fn ];; return select(items, (function() { - if (arguments.length > 0) - throw new Error("argument count mismatch: expected no arguments"); - return (!fn.apply(undefined, args)); })); }); diff --git a/lib/options.js b/lib/options.js index 249a329..08334bd 100644 --- a/lib/options.js +++ b/lib/options.js @@ -57,9 +57,6 @@ var extractOptions = (function(config, args) { }); ; var resetLabel = (function() { - if (arguments.length > 0) - throw new Error("argument count mismatch: expected no arguments"); - return currentLabel = defaultLabel;; }); ; diff --git a/lib/sibilant.js b/lib/sibilant.js index 97d2288..a67b8d9 100644 --- a/lib/sibilant.js +++ b/lib/sibilant.js @@ -19,18 +19,12 @@ var tokenize = sibilant.tokenize = (function(string) { }); ; var increaseNesting = (function() { - if (arguments.length > 0) - throw new Error("argument count mismatch: expected no arguments"); - var newArr = [ ];; acceptToken(newArr); return parseStack.unshift(newArr); }); ; var decreaseNesting = (function() { - if (arguments.length > 0) - throw new Error("argument count mismatch: expected no arguments"); - specials.shift(); parseStack.shift(); return (function() { @@ -179,8 +173,6 @@ macros.progn = (function(body) { macros.call = (function(fnName, args) { // fnName:required args:rest - if (arguments.length < 1) - throw new Error("argument count mismatch: expected no fewer than 1 arguments"); var args = Array.prototype.slice.call(arguments, 1); return (translate(fnName) + "(" + (map(args, translate)).join(", ") + ")"); @@ -188,8 +180,6 @@ macros.call = (function(fnName, args) { macros.defun = (function(fnName, argsAndBody) { // fnName:required argsAndBody:rest - if (arguments.length < 1) - throw new Error("argument count mismatch: expected no fewer than 1 arguments"); var argsAndBody = Array.prototype.slice.call(arguments, 1); var fnNameTr = translate(fnName), @@ -205,8 +195,6 @@ macros.defun = (function(fnName, argsAndBody) { macros.defmacro = (function(name, argsAndBody) { // name:required argsAndBody:rest - if (arguments.length < 1) - throw new Error("argument count mismatch: expected no fewer than 1 arguments"); var argsAndBody = Array.prototype.slice.call(arguments, 1); var js = macros.lambda.apply(undefined, argsAndBody), @@ -282,36 +270,13 @@ var buildArgsString = (function(args, rest) { }; })(); })); - var argumentCountMismatch = (function(msg) { - // msg:rest - var msg = Array.prototype.slice.call(arguments, 0); - - return indent(("throw new Error(\"argument " + "count mismatch: " + (msg).join(" ") + "\");")); - }); - ; - (function() { + return (function() { if (typeof(rest) !== 'undefined') { - (function() { - if (((args.length - optionalCount) > 0)) { - return argsString = (argsString + "if (arguments.length < " + (args.length - optionalCount) + ")" + argumentCountMismatch("expected no fewer than", (args.length - optionalCount), "arguments"));; - }; - })(); - return argsString = (argsString + "var " + translate((rest)[1]) + " = Array.prototype.slice.call(arguments, " + args.length + ");\n");;; + return (argsString + "var " + translate((rest)[1]) + " = Array.prototype.slice.call(arguments, " + args.length + ");\n"); } else { - return (function() { - if (((args).length === 0)) { - return argsString = (argsString + "if (arguments.length > 0)" + argumentCountMismatch("expected no arguments"));; - } else { - return (function() { - if ((0 > optionalCount)) { - return argsString = (argsString + "if (argument.length < " + (args.length - optionalCount) + " || arguments.length > " + args.length + ")" + argumentCountMismatch("expected between", (args.length - optionalCount), "and", args.length, "arguments"));; - }; - })(); - }; - })(); + return argsString; }; })(); - return argsString; }); var buildCommentString = (function(args) { @@ -331,8 +296,6 @@ var buildCommentString = (function(args) { // brain 'splode macros.lambda = (function(arglist, body) { // arglist:required body:rest - if (arguments.length < 1) - throw new Error("argument count mismatch: expected no fewer than 1 arguments"); var body = Array.prototype.slice.call(arguments, 1); var args = transformArgs(arglist), @@ -500,26 +463,17 @@ macros.include = (function(file) { }); sibilant.packageInfo = (function() { - if (arguments.length > 0) - throw new Error("argument count mismatch: expected no arguments"); - var fs = require("fs");; return JSON.parse(fs.readFileSync((__dirname + "/../package.json"))); }); sibilant.versionString = (function() { - if (arguments.length > 0) - throw new Error("argument count mismatch: expected no arguments"); - var package = sibilant.packageInfo(), path = require("path");; return (package.name + " version " + package.version + "\n(at " + path.join(__dirname, "..") + ")"); }); sibilant.version = (function() { - if (arguments.length > 0) - throw new Error("argument count mismatch: expected no arguments"); - return (sibilant.packageInfo())["version"]; }); diff --git a/src/sibilant.lisp b/src/sibilant.lisp index de29c51..4d7edca 100644 --- a/src/sibilant.lisp +++ b/src/sibilant.lisp @@ -186,48 +186,12 @@ ";")))) (incr optional-count))) - (defun argument-count-mismatch (&rest msg) - (indent (concat - "throw new Error(\"argument " - "count mismatch: " (join " " msg) "\");"))) - (if (defined? rest) - (progn - (when (> (- args.length optional-count) 0) - (setf args-string - (concat args-string - "if (arguments.length < " - (- args.length optional-count) - ")" (argument-count-mismatch - "expected no fewer than" - (- args.length optional-count) - "arguments")))) - (setf args-string - (concat args-string - "var " (translate (second rest)) - " = Array.prototype.slice.call(arguments, " - args.length ");\n"))) - - (if (empty? args) - (setf args-string - (concat args-string - "if (arguments.length > 0)" - (argument-count-mismatch - "expected no arguments"))) - (when (> 0 optional-count) - (setf args-string - (concat args-string - "if (argument.length < " - (- args.length optional-count) - " || arguments.length > " - args.length - ")" (argument-count-mismatch - "expected between" - (- args.length optional-count) - 'and args.length 'arguments)))))) - - args-string) - + (concat args-string + "var " (translate (second rest)) + " = Array.prototype.slice.call(arguments, " + args.length ");\n") + args-string)) (defun build-comment-string (args) (if (empty? args) "" diff --git a/test/test.lisp b/test/test.lisp index 65ce85b..3bed33b 100755 --- a/test/test.lisp +++ b/test/test.lisp @@ -116,10 +116,6 @@ (assert-translation "(comment (lambda () hello))" (concat "// (function() {\n" - "// if (arguments.length > 0)\n" - "// throw new Error(\"argument count mismatch: " - "expected no arguments\");\n" - "// \n" "// return hello;\n" "// })")) @@ -128,9 +124,6 @@ (assert-translation "(new (prototype a b c))" "(new prototype(a, b, c))") (assert-translation "(thunk a b c)" "(function() { - if (arguments.length > 0) - throw new Error(\"argument count mismatch: expected no arguments\"); - a; b; return c; @@ -154,9 +147,6 @@ (assert-translation "(each-key key hash a b c)" "(function() { for (var key in hash) (function() { - if (arguments.length > 0) - throw new Error(\"argument count mismatch: expected no arguments\"); - a; b; return c; @@ -174,9 +164,6 @@ (assert-translation "(scoped a b c)" "(function() { - if (arguments.length > 0) - throw new Error(\"argument count mismatch: expected no arguments\"); - a; b; return c; @@ -285,18 +272,12 @@ after-include-2();") (assert-translation "(thunk (setf b c d e))" "(function() { - if (arguments.length > 0) - throw new Error(\"argument count mismatch: expected no arguments\"); - b = c; return d = e;; })") (assert-translation "(thunk (set b c d e f))" "(function() { - if (arguments.length > 0) - throw new Error(\"argument count mismatch: expected no arguments\"); - (b)[c] = d; return (b)[e] = f;; })")