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 37FD37ED34 for ; Tue, 10 Jul 2012 13:32:10 +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=209.85.216.182; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="bobzhang1988@gmail.com"; x-sender="bobzhang1988@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail1-smtp-roc.national.inria.fr: domain of bobzhang1988@gmail.com designates 209.85.216.182 as permitted sender) identity=mailfrom; client-ip=209.85.216.182; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="bobzhang1988@gmail.com"; x-sender="bobzhang1988@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-qc0-f182.google.com) identity=helo; client-ip=209.85.216.182; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="bobzhang1988@gmail.com"; x-sender="postmaster@mail-qc0-f182.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AjwBANQR/E/RVdi2kGdsb2JhbABFpnKRBAgiAQEBAQkJDQcUBCOCIAEBAQQBAQEPAhMRCAEbEgoCAwwGEA0JBBIPCQMCAQIBDwIEDQEFAQoSBg0GAgEBDgkHh1sBAwwLnWsJA4wjgnGFPQoZJwMKV4hxAQUMik6HCAOVNoESiXKDJD6EGg X-IronPort-AV: E=Sophos;i="4.77,559,1336341600"; d="scan'208";a="166269570" Received: from mail-qc0-f182.google.com ([209.85.216.182]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 10 Jul 2012 13:32:09 +0200 Received: by qcsg15 with SMTP id g15so9350360qcs.27 for ; Tue, 10 Jul 2012 04:32:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=n9q6l5UDRH+iZxqgPPjHlzSKfGVcrXWO/Y4GRl44Z5E=; b=m+TirUm9TlKfQ2QlW5/+LEZM0we+/0qjQAcYLjzD+LAuralDD12IKX/jCeFcm2Ex/E BzcSqTA7BlzNznnxgvMnYEGcbYM9jj9Czc/z5N1WtWhx1os1xeI75yCR7Wih3qiEkFJy TYypT52qjbumstEGoWQH1K2rsFZSS+ciudh387YtFBMttitsPRrjziFJQyfu0rtHfZ7b p7Iih5qz7QWgGA1vnpBVv9nlkypAq+12S/LO61U0U5VaDH+Xb7d5J2RtveWmUQW863SB ycHSsp3E0As7PldbYLVye35U2Ng65gp0D+ev8wlScjKl5LzJ98p4hbRcd/+ifqTiozqw vGpQ== Received: by 10.224.217.66 with SMTP id hl2mr32356410qab.36.1341919928623; Tue, 10 Jul 2012 04:32:08 -0700 (PDT) Received: from Hongbos-MacBook-Air.local ([66.250.143.158]) by mx.google.com with ESMTPS id s9sm65190383qaa.7.2012.07.10.04.32.07 (version=SSLv3 cipher=OTHER); Tue, 10 Jul 2012 04:32:07 -0700 (PDT) Message-ID: <4FFC12B8.1050802@gmail.com> Date: Tue, 10 Jul 2012 07:32:08 -0400 From: Hongbo Zhang User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 MIME-Version: 1.0 To: Caml List References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Caml-list] mixing dynlink & toplevel... Hi List, (sorry if I post here twice) 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 >