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

Question : C++ classes? #29

Closed
interstar opened this issue May 17, 2019 · 2 comments

Comments

@interstar
Copy link

commented May 17, 2019

I'm really interested in the possibility of writing libraries in Clojure / Ferret that can be called from a C++ framework.

Something like gen-class in Clojure.

Is this possible? Is it part of the goal for Ferret?

@nakkaya

This comment has been minimized.

Copy link
Owner

commented May 18, 2019

It is possible to call Ferret from C++. Embeddability is a primary goal of Ferret.

;; core.clj
(defn say-hi
  ([]
   (println "Hello"))
  ([n]
   (println "Hello" n)))

Compile it. ferret core.clj. You can load core.cpp from C++.

#define FERRET_DISABLE_STD_MAIN

#include "core.cpp"

int main(){
  using namespace ferret;

  run(core::say_hi());
  run(core::say_hi(), obj<string>("Dave"));

  return 0;
}

@nakkaya nakkaya closed this May 18, 2019

@interstar

This comment has been minimized.

Copy link
Author

commented May 19, 2019

Thanks.

That looks great :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.