caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jon Harrop <jonathandeanharrop@googlemail.com>
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	[thread overview]
Message-ID: <200810040339.28784.jon@ffconsultancy.com> (raw)
In-Reply-To: <48E68FD7.7040605@wp.pl>

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


  parent reply	other threads:[~2008-10-04  1:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-27 19:27 embedding ocaml into a windows app: need gcc? Joel Reymont
2008-09-27 19:48 ` [Caml-list] " Richard Jones
2008-09-27 19:52 ` David Teller
2008-09-27 22:53 ` Mikkel Fahnøe Jørgensen
2008-10-03 21:34   ` 'Compiler' module (was: embedding ocaml into a windows app: need gcc?) Dawid Toton
2008-10-03 21:58     ` [Caml-list] " Lukasz Stafiniak
2008-10-03 22:23     ` David Teller
2008-10-04  2:39     ` Jon Harrop [this message]
2008-10-06 17:15       ` [Caml-list] 'Compiler' module Dawid Toton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200810040339.28784.jon@ffconsultancy.com \
    --to=jonathandeanharrop@googlemail.com \
    --cc=caml-list@yquem.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).