On Mon, Oct 24, 2011 at 02:58:30PM +0200, Gerd Stolpmann wrote:
> Am Montag, den 24.10.2011, 14:46 +0200 schrieb oliver:
> > On Mon, Oct 24, 2011 at 02:40:13PM +0200, Gerd Stolpmann wrote:
> > > 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).
> > [...]
> >
> > Maybe you both talk about different things...
> >
> > What you seem to talk about is not interpreter but compiler stuff,
> > and later bind it together?!
>
> Exactly. But what's the big difference? You want to run code of a
> domain-specific language.
[...]
The binding process would not be necessary.
(Or do we talk about different things here?)
>
> > I would assume, with "translating on-the-fly into Caml code"
> > is something meant that could be done via partial application.
>
> The interpretative overhead does not go away with this technique. E.g.
> looking up variables in your interpretation environment. I'd consider
> this as a micro-optimization that doesn't bring much improvement.
[...]
But it's an easy-going implementation.
You can just use OCaml directly.
The for-loop of the DSL for example is then directly
translated to a for loop in Ocaml.
For optimisation it maybe is better to work on an AST
and optimize it, before translating it to something that can be called.
I had rather the easy-going in mind, than the performance problem,
referring to the "on-the-fly" conversion.
Ciao,
Oliver
--
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