author | Alan Dipert
<alan@dipert.org> 2020-08-21 05:27:41 UTC |
committer | Alan Dipert
<alan@dipert.org> 2020-08-21 05:27:41 UTC |
parent | 1e11d996ff1f338389524d2cbf26ee4bf58bde41 |
boot.lisp | +10 | -0 |
jacl.js | +2 | -1 |
diff --git a/boot.lisp b/boot.lisp index 0913258..ad2bc9b 100644 --- a/boot.lisp +++ b/boot.lisp @@ -380,6 +380,16 @@ (declare (rest-array args)) (\. function (|apply| function args))) +(%export 'apply) +(defun apply (function &rest args) + (\. function + (|apply| function (%js "Array.from(~{})" (%unspread args))))) + +(%export 'do) +(defmacro do (vars end &body body) + `(let ,(%js "Cons.fromArray(Array.from(~{}).map(([name, val]) => Cons.listOf(name, val)))" vars) + ,@body)) + (defun %map-pairs (fun pairs) (let ((head nil) (tail nil)) diff --git a/jacl.js b/jacl.js index 6182226..77748a3 100644 --- a/jacl.js +++ b/jacl.js @@ -1362,7 +1362,7 @@ const analyzeSpecials = new Map([ body = body.slice(1); } env = name ? env.withLocalFunctions([name]) : env; - name = name ? mungeSym(name, 'flocal') : ""; + name = name ? mungeSym(name, `flocal_${env.functionEnvId(name)}`) : ""; node = makeNode('lambda', { env: env, parent: parent, @@ -2377,6 +2377,7 @@ const startRepl = async () => { const code = sb.toString(); // console.log('code="',code,'"'); const result = (new Function(`return ${code}`))(); + console.log(prstr(result)); console.log(result); } } catch (e) {