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=1.7 required=5.0 tests=AWL,DNS_FROM_RFC_ABUSE, SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 83B2FBC29 for ; Mon, 28 Aug 2006 03:30:38 +0200 (CEST) Received: from wx-out-0506.google.com (wx-out-0506.google.com [66.249.82.225]) by nez-perce.inria.fr (8.13.6/8.13.6) with ESMTP id k7S1UbNP024768 for ; Mon, 28 Aug 2006 03:30:38 +0200 Received: by wx-out-0506.google.com with SMTP id s6so1592581wxc for ; Sun, 27 Aug 2006 18:30:35 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=pGfGWRwxhBAjGXROm1Ii2px4zjdR+k2fBE0u2+/burCzVivCo0Oci/XkUz7Q94e7G/YqKUqYOsxKr5ZH2AzMJmg/q1m0TN7ERU5wJF0LoWWdh5nHZ9R185qP+K1fOSg4zOgoSfFGhRzastf3c5JujcQHwXB9ojyZcRYB808O0z4= Received: by 10.70.60.12 with SMTP id i12mr8386319wxa; Sun, 27 Aug 2006 18:30:35 -0700 (PDT) Received: by 10.70.84.13 with HTTP; Sun, 27 Aug 2006 18:30:35 -0700 (PDT) Message-ID: Date: Mon, 28 Aug 2006 13:30:35 +1200 From: "Jonathan Roewen" To: "Caml Mailing List" Subject: Re: [Caml-list] mixing dynlink & toplevel... In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: X-j-chkmail-Score: MSGID : 44F2473D.001 on nez-perce : j-chkmail score : X : 0/20 1 X-Miltered: at nez-perce with ID 44F2473D.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; dynlink:01 toplevel:01 dynlink:01 toplevellib:01 toplevellib:01 endline:01 endline:01 loadfile:01 usr:01 lib:01 ocaml:01 topstart:01 cmo:01 loadfile:01 usr:01 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 >