prefixing fn to __fn for scope safety

This commit is contained in:
Quentin Leonetti 2019-07-20 17:23:39 +02:00
parent 143a45807e
commit 3d5a17431e

View File

@ -60,7 +60,7 @@ function Lisp (input, lib) {
return interpret(input[2], new Context(lambdaScope, context)) return interpret(input[2], new Context(lambdaScope, context))
} }
}, },
fn: function (input, context) { __fn: function (input, context) {
return async function () { return async function () {
const lambdaArguments = arguments const lambdaArguments = arguments
const lambdaScope = [].reduce(function (acc, x, i) { const lambdaScope = [].reduce(function (acc, x, i) {
@ -121,7 +121,7 @@ function Lisp (input, lib) {
if (token === undefined) { if (token === undefined) {
return list.pop() return list.pop()
} else if (token === '\'(') { } else if (token === '\'(') {
input.unshift('fn') input.unshift('__fn')
list.push(parenthesize(input, [])) list.push(parenthesize(input, []))
return parenthesize(input, list) return parenthesize(input, list)
} else if (token === '(') { } else if (token === '(') {