4 ms·
It is possible to emit Emacs Lisp instead of bytecode/lapcode. This was the first code generator target actually. Easier to debug, simpler to trust (for the en
by quasilyte 9y ago
It is possible to emit Emacs Lisp instead of bytecode/lapcode. This was the first code generator target actually.
Easier to debug, simpler to trust (for the end user) and not that hard to generate.
The problem is that it is harder to implement some features of Go in terms of Emacs Lisp without going down to the virtual machine level. Best examples are arbitrary return statements (can be emulated by throw/catch) and goto.
- ruricolist 9y agoCould you implement arbitrary return with cl-block and cl-return-from?
- quasilyte 9y agoIt is technically possible, but optimal solution will require more than catch and throw (cl-lib uses them) Simple demonstration: https://pastebin.com/vXp0qPw3 https://pastebin.com/vXp0qPw3 Some S-expressions with `cl-return' can be rewritten to avoid the need of it (by the optimizer); not sure it covers 100% of the cases though.
- quasilyte 9y agoWith minor Emacs Lisp compiler patch (addition of %return, %goto and %label intrinsics), it is now possible to output Lisp that is optimal. Possible implementation (about 20 lines of code): https://github.com/Quasilyte/goism/issues/57 https://github.com/Quasilyte/goism/issues/57 Not sure if "defadvice" around "byte-compile-form" is acceptable for all users.