From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p9OCeLtM009309 for ; Mon, 24 Oct 2011 14:40:21 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AjQBADtcpU7U4366kWdsb2JhbABDhHWkHSIBAQEBCQsLBxQDIoFuAQEFI1YQCxoCJgICVwYTCYd5BqFpkTKBMIV8gRQEjE+MZowx X-IronPort-AV: E=Sophos;i="4.69,398,1315173600"; d="scan'208";a="114251985" Received: from moutng.kundenserver.de ([212.227.126.186]) by mail4-smtp-sop.national.inria.fr with ESMTP; 24 Oct 2011 14:40:15 +0200 Received: from office1.lan.sumadev.de (dslb-094-219-221-089.pools.arcor-ip.net [94.219.221.89]) by mrelayeu.kundenserver.de (node=mreu2) with ESMTP (Nemesis) id 0MCuUJ-1R9pd734oF-0096S5; Mon, 24 Oct 2011 14:40:14 +0200 Received: from [192.168.178.19] (546BF816.cm-12-4d.dynamic.ziggo.nl [84.107.248.22]) by office1.lan.sumadev.de (Postfix) with ESMTPSA id 5F1B9C00C7; Mon, 24 Oct 2011 14:40:14 +0200 (CEST) From: Gerd Stolpmann To: Diego Olivier Fernandez Pons Cc: Xavier Leroy , caml-list@inria.fr In-Reply-To: References: <4EA54BD0.8090009@inria.fr> Content-Type: text/plain; charset="UTF-8" Date: Mon, 24 Oct 2011 14:40:13 +0200 Message-ID: <1319460013.18639.90.camel@thinkpad> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:1oWPDpAgY8FxSiVFF+MjtqVVi7uSxn9aAxyB5AVPoWe V9n3DchyKIJhOqUKUh0hiI6J/+Gay+5vHuTSLlCgRWsRDM6UTX 2B0oVvxDTfY6XFkg+9+FntSlIb5ivQONWsv9MvrPQBcsZ75BU2 0oNigiZL8KstM6kggWDvC+WWgQGRgvpRViwAPeJV0LVQNiraxg xPUi0e5kWmNqBI9P7a8HYRsEt1lu+wt9y9spCurMiI4rNE9CGe IUdyY6m9YfkHrENWeP3sExGX5Xvf563Eknit1A8zcdoaprK/T3 1wX9yNsId0b5+DdIiJdP0BEMtR6vxBWGslWXfCZDpJn9is//AD wwyeRl42nJJpasO0+/MkoW6TsqP5S42UFox8QUDA9 Subject: Re: [Caml-list] How to write an efficient interpreter 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 gerd@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. ------------------------------------------------------------