From: David Vázquez Date: Sat, 6 Jul 2013 13:18:26 +0000 (+0200) Subject: Some refactoring X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=030869df1e9829e0b284b96e585bdda7d45e0602;p=jscl.git Some refactoring --- diff --git a/src/compiler.lisp b/src/compiler.lisp index 78ab64c..1c0bad1 100644 --- a/src/compiler.lisp +++ b/src/compiler.lisp @@ -20,6 +20,11 @@ (/debug "loading compiler.lisp!") +;;; Translate the Lisp code to Javascript. It will compile the special +;;; forms. Some primitive functions are compiled as special forms +;;; too. The respective real functions are defined in the target (see +;;; the beginning of this file) as well as some primitive functions. + (define-js-macro selfcall (&body body) `(call (function () ,@body))) @@ -29,25 +34,6 @@ (define-js-macro method-call (x method &rest args) `(call (get ,x ,method) ,@args)) -;;; Translate the Lisp code to Javascript. It will compile the special -;;; forms. Some primitive functions are compiled as special forms -;;; too. The respective real functions are defined in the target (see -;;; the beginning of this file) as well as some primitive functions. - -(defun interleave (list element &optional after-last-p) - (unless (null list) - (with-collect - (collect (car list)) - (dolist (x (cdr list)) - (collect element) - (collect x)) - (when after-last-p - (collect element))))) - -;;; Like CODE, but prefix each line with four spaces. Two versions -;;; of this function are available, because the Ecmalisp version is -;;; very slow and bootstraping was annoying. - ;;; A Form can return a multiple values object calling VALUES, like ;;; values(arg1, arg2, ...). It will work in any context, as well as ;;; returning an individual object. However, if the special variable diff --git a/src/utils.lisp b/src/utils.lisp index 5cb702c..d380e4c 100644 --- a/src/utils.lisp +++ b/src/utils.lisp @@ -93,3 +93,14 @@ (let ((key-val (if key (funcall key y) y)) (fn (if test-not-p (complement test-not) test))) (funcall fn x key-val))) + + +(defun interleave (list element &optional after-last-p) + (unless (null list) + (with-collect + (collect (car list)) + (dolist (x (cdr list)) + (collect element) + (collect x)) + (when after-last-p + (collect element)))))