From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by sympa.inria.fr (Postfix) with ESMTPS id CDB1B7ED46 for ; Tue, 10 Jul 2012 13:22:47 +0200 (CEST) Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of bobzhang1988@gmail.com) identity=pra; client-ip=80.91.229.3; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="gclci-caml-list@m.gmane.org"; x-sender="bobzhang1988@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail1-smtp-roc.national.inria.fr: domain of gclci-caml-list@m.gmane.org designates 80.91.229.3 as permitted sender) identity=mailfrom; client-ip=80.91.229.3; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="gclci-caml-list@m.gmane.org"; x-sender="gclci-caml-list@m.gmane.org"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: Pass (mail1-smtp-roc.national.inria.fr: domain of postmaster@plane.gmane.org designates 80.91.229.3 as permitted sender) identity=helo; client-ip=80.91.229.3; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="gclci-caml-list@m.gmane.org"; x-sender="postmaster@plane.gmane.org"; x-conformance=sidf_compatible; x-record-type="v=spf1" X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AikHAHsP/E9QW+UDgWdsb2JhbABFpnKPYAOBIQYCIgEBFiYngiABAQEDAQEBASQRJBIKEQsLDQkEEg8JAwIBAgEPAgQeEhMGAgEBDgmHYgEDBgYEB6obiDEKGScDCleId4pagUOCKYMcA5U2gRKJcod8 X-IronPort-AV: E=Sophos;i="4.77,559,1336341600"; d="scan'208";a="166268098" Received: from plane.gmane.org ([80.91.229.3]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/AES256-SHA; 10 Jul 2012 13:22:47 +0200 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1SoYWh-0005V0-Bt for caml-list@inria.fr; Tue, 10 Jul 2012 13:22:43 +0200 Received: from 66.250.143.158 ([66.250.143.158]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 10 Jul 2012 13:22:43 +0200 Received: from bobzhang1988 by 66.250.143.158 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 10 Jul 2012 13:22:43 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: caml-list@inria.fr From: Hongbo Zhang Date: Tue, 10 Jul 2012 07:22:31 -0400 Message-ID: <4FFC1077.7040607@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 66.250.143.158 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 In-Reply-To: Subject: [Caml-list] Re: mixing dynlink & toplevel... Hi List, I tried to dynlink the toplevel. It works fine when I execute some simple phrase. "Format.eprintf "%d" 3 ;;" like this, but whenever I execute some binding "let a = 3;;" Error message is like this >> Reference to undefined global `Toploop' I found this question raised in caml list years ago, did anyone find a solution for this? Many thanks On 8/27/06 9:30 PM, Jonathan Roewen wrote: > 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 >