4 ms·
A C REPL in ECL (Embeddable Common Lisp): https://www.reddit.com/r/lisp/comments/bgwtsh/fun_ecl_hack/ https://www.reddit.com/r/lisp/comments/bgwtsh/fun_ecl_hac
by TeMPOraL 7y ago
A C REPL in ECL (Embeddable Common Lisp):
https://www.reddit.com/r/lisp/comments/bgwtsh/fun_ecl_hack/ https://www.reddit.com/r/lisp/comments/bgwtsh/fun_ecl_hack/
It can be as simple as:
(defun c-repl ()
(loop (fresh-line)
(princ "c99> ")
(let* ((form (read-line))
(func (eval `(let ((*compile-verbose* nil))
(compile nil (lambda () (ffi:c-inline nil nil :void ,form)))))))
(funcall func))))
> (c-repl)
c99> printf("HELLO world!\n");
HELLO world!
c99> { for(int i=0; i<4; i++) printf("*"); printf("\n"); }
****
(Though that doesn't expose all features of C. More work is required to turn it into complete REPL.)
Fun thing is, you can just paste the above defun into your ECL REPL and execute it :).