RE: [Caml-list] How to write an efficient interpreter

2011-11-06 Thread Jon Harrop
If the language you are interpreting is quite declarative then piggy-backing on OCaml's run-time either by writing an interpreter or by compiling to OCaml code will be a big advantage. Writing a VM with a run-time as efficient as OCaml's in this context is a *lot* of work compared to writing an int

Re: [Caml-list] How to write an efficient interpreter

2011-10-26 Thread Diego Olivier Fernandez Pons
List, Thanks for your suggestions, here is a small summary of them with some comments. Options for interpreting a DSL --- 1 - Classical optimised interpreter 2 - Combinator / partial application based interpreter 3 - Emitting bytecode for any VM 4 - Em

Re: [Caml-list] How to write an efficient interpreter

2011-10-24 Thread oliver
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-lis

Re: [Caml-list] How to write an efficient interpreter

2011-10-24 Thread Gerd Stolpmann
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

Re: [Caml-list] How to write an efficient interpreter

2011-10-24 Thread 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 byte

Re: [Caml-list] How to write an efficient interpreter

2011-10-24 Thread Gerd Stolpmann
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.

Re: [Caml-list] How to write an efficient interpreter

2011-10-24 Thread Jérémie Dimino
Hi, On Mon, Oct 24, 2011 at 01:50:25PM +0200, Diego Olivier Fernandez Pons wrote: > 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

Re: [Caml-list] How to write an efficient interpreter

2011-10-24 Thread 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 (= qu

Re: [Caml-list] How to write an efficient interpreter

2011-10-24 Thread Xavier Leroy
On 10/24/2011 11:10 AM, Diego Olivier Fernandez Pons wrote: > I have to write an interpreter for a datatype rich purely applicative > language. I have already written a naive interpreter (like in programming > languages class) and was wondering what where the options for writing > something that w

Re: [Caml-list] How to write an efficient interpreter

2011-10-24 Thread Gerd Stolpmann
Am Montag, den 24.10.2011, 11:58 +0200 schrieb Gabriel Scherer: > Even staying at the "interpreter" stage, you can probably improve your > performance seriously by being careful about your implementation : use > efficient data structure (what is your implementation of variable > lookup?), avoid unn

Re: [Caml-list] How to write an efficient interpreter

2011-10-24 Thread Gabriel Scherer
Even staying at the "interpreter" stage, you can probably improve your performance seriously by being careful about your implementation : use efficient data structure (what is your implementation of variable lookup?), avoid unnecessary allocation, use tail-recursive functions where possible, etc. T

[Caml-list] How to write an efficient interpreter

2011-10-24 Thread Diego Olivier Fernandez Pons
Caml-list, I have to write an interpreter for a datatype rich purely applicative language. I have already written a naive interpreter (like in programming languages class) and was wondering what where the options for writing something that would perform better while keeping it maintainable by