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.1 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 377F8BC69 for ; Fri, 13 Apr 2007 21:38:52 +0200 (CEST) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.183]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l3DJcpE6010062 for ; Fri, 13 Apr 2007 21:38:52 +0200 Received: from [84.59.101.27] (helo=gate.lan.gerd-stolpmann.de) by mrelayeu.kundenserver.de (node=mrelayeu3) with ESMTP (Nemesis), id 0MKxQS-1HcRbc3wVc-0001Ku; Fri, 13 Apr 2007 21:38:51 +0200 Received: from flakew.lan.gerd-stolpmann.de (fw.lan.gerd-stolpmann.de [192.168.1.1]) by gate.lan.gerd-stolpmann.de (Postfix) with ESMTP id A9486C094; Fri, 13 Apr 2007 21:38:48 +0200 (CEST) Subject: RE: [Caml-list] Saving the OCaml interpreter state From: Gerd Stolpmann To: "Harrison, John R" Cc: caml-list@yquem.inria.fr In-Reply-To: <509223F0BF55E74FA1247D17207E7A0C0151BA6B@orsmsx419.amr.corp.intel.com> References: <509223F0BF55E74FA1247D17207E7A0C0151BA6B@orsmsx419.amr.corp.intel.com> Content-Type: text/plain; charset=UTF-8 Date: Fri, 13 Apr 2007 21:38:47 +0200 Message-Id: <1176493128.22788.101.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.6.1 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V01U2FsdGVkX1/z74Q3VvishLTrG0uiBuSD2VwToXuiGmf/57f +oJVDVuYyrrYpJSZuqAdIoZ7RGSIjYRCiCndWDp09fv+IQFhwh b1LEaiCUfbUTqJ9j3GAbTXEJD/7srHb X-Miltered: at discorde with ID 461FDC4B.001 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 gerd:01 stolpmann:01 toplevel:01 ocaml:01 vaguely:01 stack:01 o'caml:01 bytecode:01 toploop:01 bindings:01 bytecode:01 stack:01 bindings:01 mutexes:01 Am Freitag, den 13.04.2007, 12:07 -0700 schrieb Harrison, John R: > By the way, I checked with someone who knows Poly/ML, and it turns out > that >=20 > the new mechanism can still be used to get save/restore of sessions > just by nominating >=20 > the Poly/ML toplevel as the function to export as a binary. So > although the mechanism >=20 > has changed, the basic support for saving and restoring sessions has > not vanished. >=20 > =20 >=20 > I would very much like to see some such facility in OCaml. How hard is > it? I vaguely >=20 > remember some apparent problem with closures being allocated on the > stack, but I >=20 > don=E2=80=99t recall the details. My guess is that it is not so hard for core O'Caml: dump the bytecode, the toploop bindings (using Marshal), the bytecode stack and everything the interpreter needs. You'll run into some trouble when you have values in your bindings that cannot be marshalled, e.g. open files, mutexes, database handles, etc. You'll run into big trouble, however, once you want to use external (C) libraries. There is no interface for reinitializing them after being loaded from a dumped session. This is probably the hardest part. Library initialization is usually done by the caml module that accompanies the library. This code wouldn't be executed if you just load the bytecode from a file. You'd need a second initialization path for the reload case. My thinking about this feature at all is: It is reminiscent of the time when there wasn't a real compiler, but it was practise to create a session by loading file by file into the interpreter. That was slow, and dumping the session sped that up. Note that you can do something similar with the Caml toploop by creating your own one (ocamlmktop), or by loading cmas into the default one. With some tricks it is even possible to open modules. What we don't have is a convenient way to create sessions. Maybe we can add that by recording the interactively submitted definitions, and replaying them later. Gerd > =20 > ______________________________________________________________________ > From:caml-list-bounces@yquem.inria.fr > [mailto:caml-list-bounces@yquem.inria.fr] On Behalf Of Yaron Minsky > Sent: Thursday, April 12, 2007 4:52 PM > To: Jon Harrop > Cc: caml-list@yquem.inria.fr > Subject: Re: [Caml-list] Saving the OCaml interpreter state >=20 >=20 > =20 >=20 > You should check with someone who knows better, but I suspect that if > you become a member of the OCaml consortium (which is fairly cheap) > you would have the rights to do what you propose. >=20 > y >=20 > On 4/12/07, Jon Harrop wrote: >=20 > On Thursday 12 April 2007 16:53, Harrison, John R wrote: > > | A new version of Poly ML also doesn't have the persistent storage > > > > system. > > > > Thanks; I didn't know that, and it comes as quite a surprise given=20 > > Poly's history. > > > > Still, my question about OCaml stands. More specifically, I want to > > know whether the facility to save and restore state doesn't exist > > because > > > > * None of the main OCaml developers particularly care about it=20 > > > > or > > > > * There are non-trivial technical problems implementing it. >=20 > Like Michael, I am also not going to answer your question (sorry!) but > can I > just say that, as a commercial developer, there would be significant=20 > incentive to write a killer IDE for OCaml if the current top-level was > free > for commercial use, e.g. part of the stdlib. >=20 > Having been playing with F# recently, I'm starting to appreciate some > of the > features afforded by a decent IDE. However, both OCaml and F# lack > features=20 > found in the other and, more importantly, lack many features that > could be > hugely beneficial, particularly to users of the interactive systems. >=20 > Marshalling top-level state is one such feature. >=20 > -- > Dr Jon D Harrop, Flying Frog Consultancy Ltd.=20 > OCaml for Scientists > http://www.ffconsultancy.com/products/ocaml_for_scientists >=20 > _______________________________________________ > Caml-list mailing list. Subscription management:=20 > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs >=20 >=20 > =20 >=20 >=20 > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs --=20 ------------------------------------------------------------ Gerd Stolpmann * Viktoriastr. 45 * 64293 Darmstadt * Germany=20 gerd@gerd-stolpmann.de http://www.gerd-stolpmann.de Phone: +49-6151-153855 Fax: +49-6151-997714 ------------------------------------------------------------