From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 5F86DBBAF for ; Sat, 4 Oct 2008 03:38:33 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AosBABJm5khKfU4alGdsb2JhbACBcU2QZT4BAQEBCQkMBxEDoEGGbQEC X-IronPort-AV: E=Sophos;i="4.33,359,1220220000"; d="scan'208";a="18175713" Received: from ey-out-2122.google.com ([74.125.78.26]) by mail1-smtp-roc.national.inria.fr with ESMTP; 04 Oct 2008 03:38:33 +0200 Received: by ey-out-2122.google.com with SMTP id 6so594630eyi.15 for ; Fri, 03 Oct 2008 18:38:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:organization:to:subject:date :user-agent:references:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:message-id:from; bh=Q5Gruwm3L2gqUEZBNWiEHMODd6w+2NGpWRdT9Q003gE=; b=YcP3YuExl195YMiSLJO0wrfbiOgNCB9nLxdzJg7lcBjpfUgKlnOwppJwuo5ykjgJN1 Lm1TAgzwabQvuLJL8kNytaiCytZE8OanjwujLZ6ZEScuCqg3WZLMLGaNsYuqfOX+RAy2 Ndj28HMV/+XwgSKgY5yHfx/zqWhhNnyHWwxCM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=organization:to:subject:date:user-agent:references:in-reply-to :mime-version:content-type:content-transfer-encoding :content-disposition:message-id:from; b=caBnxA/o+Nh32pspahE5aE6rvLLOEdsNwBaF1FFR+6RYcrboFXwt7aCUEMaJyV1oQW DAPyx36D4dWudafp5z8Zfwkvo/VdbME6/ZeS40m+gGs5sw/rpdkmGLRg4tDlNGposYyC /HYkfIEfTqW5/6nmGjH63EGlJ5mpujys3Ja6s= Received: by 10.210.115.17 with SMTP id n17mr2215588ebc.62.1223084312067; Fri, 03 Oct 2008 18:38:32 -0700 (PDT) Received: from leper.local (host86-139-250-145.range86-139.btcentralplus.com [86.139.250.145]) by mx.google.com with ESMTPS id t12sm6927526gvd.4.2008.10.03.18.38.31 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 03 Oct 2008 18:38:31 -0700 (PDT) Organization: Flying Frog Consultancy Ltd. To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] 'Compiler' module (was: embedding ocaml into a windows app: need gcc?) Date: Sat, 4 Oct 2008 03:39:28 +0100 User-Agent: KMail/1.9.9 References: <1253374D-FC84-4394-99E5-46C02D26C54C@gmail.com> <48E68FD7.7040605@wp.pl> In-Reply-To: <48E68FD7.7040605@wp.pl> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200810040339.28784.jon@ffconsultancy.com> From: Jon Harrop X-Spam: no; 0.00; ocaml:01 gcc:01 ocaml:01 compiler:01 sig:01 val:01 val:01 python's:01 compiler:01 run-time:01 compilation:01 vastly:01 python's:01 bytecode:01 camlp:01 On Friday 03 October 2008 22:34:15 Dawid Toton wrote: > > I would like an OCaml support library that can compile and execute > > similar to JaveScript engines, but we don't have that in any practical > > form. > > I also need this and I'm thinking about something like this: > > module type Compiler = > sig > val parse : Context.t -> string -> (Context.t * AST.t) > val get_type : Context.t -> AST.t -> Type.t; > val eval : Context.t -> AST.t -> Context.t * (Type.t * > MarshalledValueOrSomething.t) > end > > Is it really so hard to have it in OCaml? The OCaml compiler's current design makes it extremely difficult but it is certainly entirely feasible (F# already does this, for example). > I'm envy of Python's Compiler module. Given that the sole objective of run-time compilation is performance and Python is vastly slower than OCaml, why are you the envy of Python's Compiler (to interpreted bytecode) module? > It could solve some of my problems, in particular for my 'parallel-like' > evaluation ( > http://www.nabble.com/'Nondeterministic'-evaluation-wrt-exceptions-td186539 >98.html ). After some experimentation I know that I need type information > during code transformation. I want to create a sort of interpreter. I think (as Zheng implied) you want asynchronous workflows from F#. Note that these also handle cleanup of resources. > That Compiler module would also enable me to have an editor with > graphical representation of results intermixed with code (like > Mathematica's notebook). For a decent editor, you will need a lot more than that. I would certainly love to have such a thing but you also need access to the type checking phase to throwback type errors and having the data available in an efficient and accessible form would certainly be preferable. I believe you can lex and parse OCaml using Camlp4 and then invoke the OCaml compiler with -dtypes to get the results of type checking. However, the latter is extremely inefficient. You really want the ability to restart the compiler from the end of the previous definition each time a file is edited. > Where to look for suitable pieces of code? AFAIK camlp4 modules can't > tell me type of anything. Should I start digging in OCaml compiler sources? I'd start by reviewing asynchronous workflows. -- Dr Jon Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?e