News for hackers. Stuff that matters.
Re:Swift as a C Language REPL by TeMPOraL on Thursday January 02, 2020 @02:13PM (#21938635)
A C REPL in ECL (Embeddable Common Lisp):

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 :).

There are no comments on this comment yet.