Open aadcg opened 2 years ago
I don't agree! We need:
define-parenscript
).peval
).pflet
).
setf
/writers equivalently working in both Lisp and JS worlds.cl-uglify-js
partially doing that).Which represents another vision: the vision of fuzing Lisp and JS, as a desire to add a nice syntax and data model to an otherwise unescapably dominant JavaScript.
Oh, and we also need a way to generically interact with our interfaces, for those renderers that we might need to support and that don't have JS (#2433 is probably a better place for this point).
Lisp function that will call JS with Lisp arguments (define-parenscript).
How does that differ from peval
? Besides, have you wondered why most of the entities defined with define-parenscript
take no arguments?
Lisp function that will call JS with Lisp arguments (define-parenscript).
How does that differ from
peval
?
It assigns it to a certain globally accessible name and abstracts away the details (as any function does), for one :)
Besides, have you wondered why most of the entities defined with
define-parenscript
take no arguments?
I haven't :P
I believe you haven't understood my points. We're conflating two different things: generating JS, and evaluating it. I'll draft a PR soon.
I've understood your points, and I'm answering to those: we need to conflate those, exactly because we can't put JS in a can and ignore it until we require it. We need to dynamically interop with JS, in all its grotesque ubiquity.
Firstly, an overview.
There are always 2 steps:
ps:ps
and others);ffi-buffer-evaluate-javascript
orffi-buffer-evaluate-javascript-async
).Unfortunately, the macros from
renderer-script.lisp
conflate both. There should be a single macro to handle step 2 (peval
, which should be renamed tops-eval
btw).Regarding the former, we could just use regular CL functions defined with
defun
. Example:But, arguably, it is confusing to define functions that output valid JS code as a string with
defun
. Perhaps it should be defined withdefps
. The computer doesn't care, humans do.defps
would simply be:(There's also
ps:ps*
, another method to compile to JS).Notice that once JS functions are evaluated (step 2) they will belong to the JS environment and they can be referenced with
(ps:ps (add 4))
("add(4);"
). Still, we can't control the way the renderer garbage collects the environment (I assume).Actions:
peval
tops-eval
pflet
define-parenscript
defps