Re: [Caml-list] Re: How to wrap around C++?

2010-02-08 Thread Basile STARYNKEVITCH
Guillaume Yziquel wrote: Essentially, the garbage collector will run potentially each time you allocate an OCaml value. caml_copy_string? the GC may run. The garbage collector may also run when calling (from C or C++ code) a callback, that is a function like caml_callback ... (see section 18.7

Re: [Caml-list] Preventing values from escaping a context

2010-02-08 Thread Yaron Minsky
On Mon, Feb 8, 2010 at 10:07 PM, Rich Neswold wrote: > (I realize that making this context a monad is a legitimate solution. > However, until I see the Ocaml community including monads in the standard > library, I think I'll stick with idiomatic Ocaml. I'd also like to solve > this functionally, s

Re: [Caml-list] Preventing values from escaping a context

2010-02-08 Thread Jacques Garrigue
From: Rich Neswold > Most of the functions in my library take a parameter that describes the > current environment. I call this data type, "context". The context is passed > to a function which will then use other functions in the library to get its > job done. The signature of the function that

[Caml-list] Preventing values from escaping a context

2010-02-08 Thread Rich Neswold
Hello, I'm writing my first serious Ocaml library and have a question, which I'll state later on. Most of the functions in my library take a parameter that describes the current environment. I call this data type, "context". The context is passed to a function which will then use other functions

[Caml-list] Re: How to wrap around C++?

2010-02-08 Thread Michael Ekstrand
On 02/08/2010 10:03 AM, Luca de Alfaro wrote: > Thank you very much! I follow the general lines, but... > > * Make sure no C++ exceptions leak to OCaml. > > This will be next to impossible: the C++ code I need to wrap is huge, > and I have no idea of what possible exceptions can be generated

RE: [Caml-list] Power serious

2010-02-08 Thread Harrison, John R
Hi Jon, | I stumbled upon the following article that describes a remarkably simple | implementation of arithmetic over power series in Haskell: | | http://www.cs.dartmouth.edu/~doug/powser.html | | This is the only compelling example of Haskell I have ever seen and I'd like | to see this rewritt

Re: [Caml-list] Re: How to wrap around C++?

2010-02-08 Thread Luca de Alfaro
Thank you Guillaume. The reason why it is complex for me to use C/C++ inside Ocaml is that it is a huge, and hugely complex, body of C/C++ code, that comes with all sort of nonstandard things, and with its own entire build process. It is not clear to me what happens if the main file is not some ve

Re: [Caml-list] Re: How to wrap around C++?

2010-02-08 Thread Guillaume Yziquel
Luca de Alfaro a écrit : Thank you very much! I follow the general lines, but... * Wrap your OCaml includes in 'extern "C" { ... }" Here, I am not sure what you mean. You mean, extern "C" { #include ... } ? See the code in my email: /* Including OCaml system. */ #define CAML_VALU

Re: [Caml-list] Re: How to wrap around C++?

2010-02-08 Thread Guillaume Yziquel
Luca de Alfaro a écrit : I am trying another approach... it might make more sense for me to embed the Ocaml into C++. This is not the way you'll get the most help out of this list. People are more familiar with making C bindings. Making C++ bindings is rather close to it. I have read the i

Re: [Caml-list] camlp4 unbound value

2010-02-08 Thread blue storm
The problem I've seen when testing your code is slightly different from the one you reported : Camlp4 choke on the "Relational.Conv_..." string as containing different identifiers. The problem is that "A.B" is not a legal uid, so you can't use it in a $uid:...$ antiquotation. I've fixed this by us

Re: [Caml-list] Re: How to wrap around C++?

2010-02-08 Thread Luca de Alfaro
I am trying another approach... it might make more sense for me to embed the Ocaml into C++. I have read the instructions, and it seems feasible, except that I have a few questions: - All I need to pass, as arguments, are int, float, string, and arrays of these. Any example of how to deal w

Re: [Caml-list] out of memory error

2010-02-08 Thread Damien Doligez
Hello, On 2010-02-02, at 14:31, Kihong Heo wrote: Can't I use "ocamlrun -v" for my program such that it use foreign language interface with C. If I couldn't, can you give me a good debugging methodology? It's very difficult to find out that error because of using foreign language interface.

Re: [Caml-list] Re: How to wrap around C++?

2010-02-08 Thread Luca de Alfaro
Thank you very much! I follow the general lines, but... > * Make sure no C++ exceptions leak to OCaml. > This will be next to impossible: the C++ code I need to wrap is huge, and I have no idea of what possible exceptions can be generated. I will have to try to see if there is a generic except

Re: [Caml-list] How to wrap around C++?

2010-02-08 Thread Guillaume Yziquel
Luca de Alfaro a écrit : I need to be able to call some C++ functions from my Ocaml code. Can someone point me to some examples on how this is done? Is it an issue if what I need to wrap is C++, rather than the more standard C? I also would like to know if I can do something more complex... nam

Re: [Caml-list] Power serious

2010-02-08 Thread David McClain
I believe that you'll find this stuff in SICP too... I know I have plenty of Lisp and Scheme examples of this sort of thing... e.g., computing tan from the ratio of the sin and cos series, done in lazy streams along with series convergence acceleration, a la John Houston's paper... - DM On Feb

[Caml-list] camlp4 unbound value

2010-02-08 Thread Guillaume Yziquel
Hi. This is for camlp4 gurus: I've been using a modified version of Mauricio Fernandez' relational algebra camlp4 extension for postgresql. (I'm trying to adapt it to another database system, so I've functorised a bit of the original code). You can find the modified code and a Debian package