nakkaya / ferret

Ferret is a free software lisp implementation for real time embedded control systems.

Home Page:https://ferret-lang.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

REPL in ferret

arichiardi opened this issue · comments

Hi!

I have discovered this project while looking for a way to build a parser targeting C, exposing therefore a C libray.

The plan I have read on HN about the REPL is to emit C++ directly to https://root.cern.ch/cling. Sounds nice. For me the REPL is the biggest (or maybe second, after persistent data structures) innovation Lisp introduced and I would love to have one in ferret.

I cannot commit any time but I will look into it, any hint/update on this can go in this issue.

Thanks for working on this, it is super awesome (and the literate file is super!).

commented

a very nice feature ,support

Any updates on the REPL?

I've been researching this. I've found a bunch of projects that promises a C++ REPL. But I did not have time to check them one by one and see which one would work best yet. I am gonna organize the links and dump it over here for reference.

Notes on Cling

Prebuilt versions are available from [1]. Generated code is compatible. Ferret generated C++ code be loaded and called.

;;core.clj
(defn adder [x] (fn [y] (+ x y)))

Once compiled to C++ generated code can be loaded into cling,

src/(master) $ cling

****************** CLING ******************
* Type C++ code and press enter to run it *
*             Type .q to exit             *
*******************************************
[cling]$ .L core.cpp
[cling]$ using namespace ferret;  
[cling]$ var fn = run(core::adder(), obj<number>(1)); 
[cling]$ var res = run(fn, obj<number>(5));   
[cling]$ number::to<number_t>(res)
(int) 6

Only problem I've noticed so far is that you can not redifine vars.

[1] https://root.cern.ch/download/cling/

Looks like we will need stuff like var bindings and defonce.

Another example to consider is Dale. This is a Lisp that targets C and has a REPL.
https://github.com/tomhrr/dale