Am Montag, den 24.10.2011, 13:50 +0200 schrieb Diego Olivier Fernandez Pons: > Caml-list, > > > Xavier Leroy wrote > > Compiling to bytecode is probably overkill. > > > > I think that writing my own bytecode interpreter is looking for > trouble. Same for compiling to an existing bytecode. > > > The language being a kind of SQL, most of the work is to properly > execute the comprehensions (= queries). > > > For instance > > > range numbers = 0 .. 100; > {int} sqrtLessThan [k in numbers] = { x | x in numbers : x * x > <= k }; > > > There are smarter ways to implement this than a double loop > > > I was rather thinking of translating on-the-fly into Caml code and > letting Caml do the job. Is that technically possible (rewriting a > toplevel ? a CamlP4 grammar ?). If so guess I would have to license > the Caml compiler from the INRIA.
I don't think you need that, because you can load compiled OCaml code dynamically (look into the Dynlink library). This works with both bytecode and native code (in recent OCaml versions). This way you just invoke the compiler via the normal ocamlc or ocamlopt executable, and you don't need to change the compiler (for which you would need the license). If you prefer to include the OCaml compiler directly into your "interpreter", you probably get only a very small speedup when "loading" code (the overhead of spawning a new process is small). This is IMO only worth it if you load code very frequently. Gerd > > > > > Diego Olivier -- ------------------------------------------------------------ Gerd Stolpmann, Darmstadt, Germany g...@gerd-stolpmann.de Creator of GODI and camlcity.org. Contact details: http://www.camlcity.org/contact.html Company homepage: http://www.gerd-stolpmann.de *** Searching for new projects! Need consulting for system *** programming in Ocaml? Gerd Stolpmann can help you. ------------------------------------------------------------ -- Caml-list mailing list. Subscription management and archives: https://sympa-roc.inria.fr/wws/info/caml-list Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs