var startPrompt = function () {
// Start the prompt with history enabled.
- jqconsole.Write(lisp.evalString('(CL:PACKAGE-NAME CL:*PACKAGE*)') + '> ', 'jqconsole-prompt');
+ jqconsole.Write(lisp.evalString(id, '(CL:PACKAGE-NAME CL:*PACKAGE*)') + '> ', 'jqconsole-prompt');
jqconsole.Prompt(true, function (input) {
// Output input with the class jqconsole-return.
if (input[0] != ','){
try {
- jqconsole.Write(lisp.print(lisp.evalString(input)) + '\n', 'jqconsole-return');
+ jqconsole.Write(lisp.print(id, lisp.evalString(id, input)) + '\n', 'jqconsole-return');
} catch(error) {
jqconsole.Write('ERROR: ' + (error.message || error) + '\n', 'jqconsole-error');
}
} else {
- jqconsole.Write(lisp.compileString(input.slice(1)) + '\n', 'jqconsole-return');
+ jqconsole.Write(lisp.compileString(id, input.slice(1)) + '\n', 'jqconsole-return');
}
// Restart the prompt.
startPrompt();
}, function(input){
try {
- lisp.read(input[0]==','? input.slice(1): input);
+ lisp.read(id, input[0]==','? input.slice(1): input);
} catch(error) {
return 0;
}
(lambda-docstring-wrapper
documentation
"(function ("
- (join (mapcar #'translate-variable
- (append required-arguments optional-arguments))
+ (join (cons "values"
+ (mapcar #'translate-variable
+ (append required-arguments optional-arguments)))
",")
"){" *newline*
;; Check number of arguments
(indent
(if required-arguments
- (concat "if (arguments.length < " (integer-to-string n-required-arguments)
+ (concat "if (arguments.length < " (integer-to-string (1+ n-required-arguments))
") throw 'too few arguments';" *newline*)
"")
(if (not rest-argument)
(concat "if (arguments.length > "
- (integer-to-string (+ n-required-arguments n-optional-arguments))
+ (integer-to-string (+ 1 n-required-arguments n-optional-arguments))
") throw 'too many arguments';" *newline*)
"")
;; Optional arguments
(if optional-arguments
- (concat "switch(arguments.length){" *newline*
+ (concat "switch(arguments.length-1){" *newline*
(let ((optional-and-defaults
(lambda-list-optional-arguments-with-default lambda-list))
(cases nil)
(let ((js!rest (translate-variable rest-argument)))
(concat "var " js!rest "= " (ls-compile nil) ";" *newline*
"for (var i = arguments.length-1; i>="
- (integer-to-string (+ n-required-arguments n-optional-arguments))
+ (integer-to-string (+ 1 n-required-arguments n-optional-arguments))
"; i--)" *newline*
(indent js!rest " = "
"{car: arguments[i], cdr: ") js!rest "};"
(define-raw-builtin funcall (func &rest args)
(concat "(" (ls-compile func) ")("
- (join (mapcar #'ls-compile args)
+ (join (cons "id" (mapcar #'ls-compile args))
", ")
")"))
(last (car (last args))))
(js!selfcall
"var f = " (ls-compile func) ";" *newline*
- "var args = [" (join (mapcar #'ls-compile args)
+ "var args = [" (join (cons "id" (mapcar #'ls-compile args))
", ")
"];" *newline*
"var tail = (" (ls-compile last) ");" *newline*
(if (and (symbolp function)
(claimp function 'function 'non-overridable))
(concat (ls-compile `',function) ".fvalue("
- (join (mapcar #'ls-compile args)
+ (join (cons "id" (mapcar #'ls-compile args))
", ")
")")
(concat (ls-compile `#',function) "("
- (join (mapcar #'ls-compile args)
+ (join (cons "id" (mapcar #'ls-compile args))
", ")
")")))