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 p9OCx1vM010292 for ; Mon, 24 Oct 2011 14:59:01 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AjQBAMBfpU7U4xEKkGdsb2JhbABDhHWkHSIBAQEBCQkNBxQDIoFuAQEEASNRBQULCxgCAiYCAlcGEwmHdwIGoX2RMoEwhXyBFASMT4xmjDE X-IronPort-AV: E=Sophos;i="4.69,398,1315173600"; d="scan'208";a="114259105" Received: from moutng.kundenserver.de ([212.227.17.10]) by mail4-smtp-sop.national.inria.fr with ESMTP; 24 Oct 2011 14:58:33 +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=mreu0) with ESMTP (Nemesis) id 0Mhh2N-1ReY3P0aeJ-00MYJn; Mon, 24 Oct 2011 14:58:32 +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 AFAC7C00C7; Mon, 24 Oct 2011 14:58:31 +0200 (CEST) From: Gerd Stolpmann To: oliver Cc: Diego Olivier Fernandez Pons , Xavier Leroy , caml-list@inria.fr In-Reply-To: <20111024124617.GA2287@siouxsie> References: <4EA54BD0.8090009@inria.fr> <1319460013.18639.90.camel@thinkpad> <20111024124617.GA2287@siouxsie> Content-Type: text/plain; charset="UTF-8" Date: Mon, 24 Oct 2011 14:58:30 +0200 Message-ID: <1319461110.18639.96.camel@thinkpad> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:kZWaLndTR4HdsATKGVATSCg2xZ/k1AWZku/EVdwlnzB 3TENIUHzMmioVlDcazaeqd3JPRlBrTQyXSh5XxJl55ZEYVPRhc Pr0wpSP3rLi19QRyxWxR5gc4SGiNR1mMDqssJjFMuvjGMPWIiJ uZrHLf75MaQCQZKwZYGOdeQkrHLPrc1gTN7L1WKluiokZb1xZ/ G738WyVysYCEIC+ZQ2A26pcIWfVMapmD5hw2fCco3g3XeEPg+a yf5RuDRnCc1cVwjLGNPeKhwCPhcXDaj7ZeUf/kytBpURDNKuWy gU5KpOaK6AS3a2P71VAGRRz3zROglz3Y2ktdvPd58ITg3i0tc6 e3l0ueUDH+/Nnfzr0juCUyYmOtFd+0stYS9HsroDa Subject: Re: [Caml-list] How to write an efficient interpreter 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. > 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. Gerd > Parsing the language that you implement, and create partial > applicated functions of OCaml-code that do the work. > > This can be done straight forward and nearly "ad hoc". > It's an easy way to go. Yo can create such partial applicated functions > while prsing or from an AST that you construct in parsing stage. > > Ciao, > Oliver > -- ------------------------------------------------------------ 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. ------------------------------------------------------------