author | Alan Dipert
<alan@dipert.org> 2019-09-24 05:02:37 UTC |
committer | Alan Dipert
<alan@dipert.org> 2019-09-24 05:02:37 UTC |
parent | 98be92db0223ff2be085245c261ff9472709980e |
jacl.js | +7 | -10 |
notes.txt | +38 | -0 |
diff --git a/jacl.js b/jacl.js index c7492b3..2f160b8 100644 --- a/jacl.js +++ b/jacl.js @@ -556,13 +556,10 @@ class Reader { } } -const compileDot = (form, env, retctx) => { - [, topic, ...[arg, ...more]] = form; - const ctopic = compile(topic, env, retctx); - if (arg instanceof LispSymbol) { - return `${ctopic}.${arg.name}`; - } -}; +const JSPKG = Package.makePackage('JS'); + +JSPKG.intern('GLOBAL'); +JSPKG.exportSymbol('GLOBAL'); const compile = (form, env, retctx) => { if (retctx) { @@ -573,9 +570,9 @@ const compile = (form, env, retctx) => { } else if (form instanceof Cons) { const car = form.car; if (car instanceof LispSymbol - && car.getPackage().name === 'JACL' - && car.name === '.') { - return compileDot(form, env, retctx); + && car.getPackage().name === 'JS' + && car.name === 'GLOBAL') { + return form.cdr.car.name; } } } else { diff --git a/notes.txt b/notes.txt new file mode 100644 index 0000000..61ac84d --- /dev/null +++ b/notes.txt @@ -0,0 +1,38 @@ +(use-package :js) + +; js::global +; js::window +; js::dot +; js::js-string +; js::enable-js-syntax (for @"js strings") +; js::+null+ +; js::+true+ +; js::+false+ +; js::+undefined+ +; js::\. + +; global reference +; JS: window +(global |window|) +window + +; field access +: JS: window.location +(dot window |location|) + +(let ((win window)) + (dot win |location|)) + +; method call +; JS: window.alert("hello!") +((dot window |alert|) (js-string "hello!") + +; add JS string literals like @"foo" (equivalent to (js-string "foo")) +(eval-when (:compile-toplevel :load-toplevel :execute) + (enable-js-syntax)) + +; sugared method call +(\. window (alert @"hello!")) + + +