Standard library function conversion
When compiling CL functions to JS, there are quite a few functions that don't get translated correctly.
For example, parse-integer
becomes parseInteger
, while the JS version would be parseInt
(yeah, and additional parameters are different as well).
I'm now pondering the design of such a translation layer.
Basically, there need to be functions defined that take a CL function call (with the actual parameter values translated to variables, so that (parse-integer input :start (+ 5 2))
would be passed as arguments input :start #:gensym15
with the gensym prepared outside.
The big question is, how should this translation table be stored?
- Have a
ps:translate
property on each symbol to be translated. +: Clean separation; -: only possible for already-loaded packages. - Have a hash-table index by the string representation of each symbol for which a translation is available. +: can be loaded before other libraries; -: a bit performance impact for converting to strings, won't be garbage collected when minimizing an image.
- Have some solution that tries to load additional translations when packages have been added. +: clean and extensible, only required translations loaded; -: when/how should we detect new packages?
Thanks for all other ideas here.