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 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id EB014BC29 for ; Mon, 28 Aug 2006 11:41:47 +0200 (CEST) Received: from mx.laposte.net (mx.laposte.net [81.255.54.11]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id k7S9fle2004389 for ; Mon, 28 Aug 2006 11:41:47 +0200 Received: from [82.236.97.29] (82.236.97.29) by mx.laposte.net (7.2.060.1) (authenticated as san.vu-ngoc) id 44D1ABB6009D7F50; Mon, 28 Aug 2006 11:41:38 +0200 Message-ID: <44F2BA4E.4000103@laposte.net> Date: Mon, 28 Aug 2006 11:41:34 +0200 From: Vu Ngoc San User-Agent: Thunderbird 1.5.0.5 (X11/20060812) MIME-Version: 1.0 To: Jonathan Roewen Cc: Caml Mailing List Subject: Re: [Caml-list] mixing dynlink & toplevel... References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Miltered: at concorde with ID 44F2BA5B.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; dynlink:01 toplevel:01 toplevellib:01 ocaml:01 dynlink:01 toplevellib:01 endline:01 endline:01 loadfile:01 usr:01 lib:01 ocaml:01 topstart:01 cmo:01 loadfile:01 By the way, is there somewhere a doc for toplevellib ? It is not in the "official" ocaml manual, and, googgleing a little bit, I could not find anything. Best San Jonathan Roewen a écrit : > Well, I've solved my own problem. Mind you, I am known for doing > things that are not expected/thought of... > > Turns out it was a double initialisation problem as dynlink & > toplevellib share some modules. > > On 8/28/06, Jonathan Roewen wrote: >> > Hi, >> > >> > I dunno if this is possible, but: if I use Dynlink, can I later load >> > toplevellib.cma, and use it like normal? At the moment I get undefined >> > reference to global 'Toploop'. >> > >> > Jonathan >> >> I've just made a small test case to demonstate: >> >> test.ml: >> open Dynlink >> >> let () = try >> print_endline "init"; >> Dynlink.init (); >> print_endline "allowing unsafe modules"; >> Dynlink.allow_unsafe_modules true; >> print_endline "loading toplevellib.cma"; >> Dynlink.loadfile "/usr/local/lib/ocaml/toplevellib.cma"; >> print_endline "loading topstart.cmo"; >> Dynlink.loadfile "/usr/local/lib/ocaml/topstart.cmo"; >> (* now the ocaml toplevel should be running *) >> with Dynlink.Error error -> print_endline (Dynlink.error_message error);; >> >> To compile: ocamlc -o test -linkall dynlink.cma test.ml >> >> Running: >> colinux:~/test# ./test >> init >> allowing unsafe modules >> loading toplevellib.cma >> loading topstart.cmo (shouldn't return) >> Objective Caml version 3.09.2 >> >> # let s = "hello world";; >> Reference to undefined global `Toploop' >> # exit 0;; >> colinu:~/test# >> >> As you can see, it can run functions fine (e.g. calling >> Pervasives.exit), but let bindings fail. >> >> I know that a module loaded via Dynlink.loadfile can call functions >> defined by other modules loaded by Dynlink.loadfile before it (I >> actually do this), so why can't the toplevel access these? It can only >> access those of the original program from my testing. >> >> Jonathan >> > > _______________________________________________ > 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 >