From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id VAA13665; Fri, 11 Oct 2002 21:02:10 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id VAA14539 for ; Fri, 11 Oct 2002 21:02:09 +0200 (MET DST) Received: from relay.pair.com (relay1.pair.com [209.68.1.20]) by nez-perce.inria.fr (8.11.1/8.11.1) with SMTP id g9BJ28D06744 for ; Fri, 11 Oct 2002 21:02:08 +0200 (MET DST) Received: (qmail 82559 invoked from network); 11 Oct 2002 19:02:06 -0000 Received: from node-d8e9cca2-sfo-onnet.worldcom.com (HELO checkerlap.d6.com) (216.233.204.162) by relay1.pair.com with SMTP; 11 Oct 2002 19:02:06 -0000 X-pair-Authenticated: 216.233.204.162 Message-Id: <4.3.2.7.2.20021011113853.04c03c08@mail.d6.com> X-Sender: checker@mail.d6.com X-Mailer: QUALCOMM Windows Eudora Version 4.3.2 Date: Fri, 11 Oct 2002 11:53:13 -0700 To: Alessandro Baretta , Ocaml From: Chris Hecker Subject: Re: [Caml-list] PostgreSQL and Ocaml In-Reply-To: <3DA6B04E.1090900@baretta.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk >If nobody has, would anyone like to join me in the project of writing an >add-in for PostgreSQL supporting Ocaml stored procedures? I have little >experience in this, but it should not be too difficult: it should be a >matter of writing a C dll which, upon initialization, starts a bytecode >compiler and interpreter, and has callbacks through with which the server >can request the compilation of a text string or the execution of a >bytecode cmo blob. I have no time to help you with this, but I have a suggestion. I would write this dll in caml and use the asmdynlink library (which, unfortunately, is bound rather tightly into the apparently-moribund cdk at this point, but it still appears to work). I'm planning on using asymdynlink for some of my game work, and it appears to be just the trick for using caml as a dynamic scripting language (you can eval strings, load cmo files, the loaded caml can call native caml code transparently, etc.). This would allow you to write 90% of the dll in native mode caml, and still dynaload programs. There are two main issues I've found that I will probably try to solve: 1. You need to have all the cmi files around, which is annoying and a logistical nightmare. This is true of the toplevel and the regular bytecode dynlink library too, and it sucks. The optimal solution would be to bind in all the cmis as data resources into the program. Slightly less optimal but still better than nothing would be to use the -pack option, get a single big .cmi, and use that. I think you'd have to -pack the whole standard library first, and then link with that because the modules will now be nested in the pack module. 2. The asmdynlink interpreter is supposedly fairly slow (I haven't done any timings yet). This is not that big of a deal for what I'm going to use it for, but if I find it is too slow, there are a couple options. First, Fabrice has a mostly-finished JIT in the cdk version. It's x86 only I think, but it might be useful. [As an aside to Fabrice and/or Xavier, why didn't the JIT generate Cmm code instead of x86, and then link in the compiler backend from the current platform, and that way it would be cross-platform? That would work, right?] The other option is to rewrite the interpreter by porting the C interpreter over the the asmdynlink environment...that should be fairly easy and should run at the same speed as the regular bytecode interpreter. Chris ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners