Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REPL in ferret #13

Open
arichiardi opened this issue Jan 15, 2018 · 7 comments
Open

REPL in ferret #13

arichiardi opened this issue Jan 15, 2018 · 7 comments

Comments

@arichiardi
Copy link

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

@mxx
Copy link

mxx commented Apr 12, 2018

a very nice feature ,support

@divs1210
Copy link

divs1210 commented Jun 3, 2018

Any updates on the REPL?

@nakkaya
Copy link
Owner

nakkaya commented Aug 2, 2018

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.

@nakkaya
Copy link
Owner

nakkaya commented Aug 7, 2018

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/

@divs1210
Copy link

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

@asimjalis
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants