From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id PAA12977; Tue, 24 Jul 2001 15:33:55 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id PAA13023 for ; Tue, 24 Jul 2001 15:33:55 +0200 (MET DST) Received: from shiva.jussieu.fr (shiva.jussieu.fr [134.157.0.129]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f6ODXsb10798 for ; Tue, 24 Jul 2001 15:33:54 +0200 (MET DST) Received: from foobar.pps.jussieu.fr (IDENT:root@foobar.pps.jussieu.fr [134.157.168.2]) by shiva.jussieu.fr (8.11.3/jtpda-5.3.3) with ESMTP id f6ODXsD59995 for ; Tue, 24 Jul 2001 15:33:54 +0200 (CEST) Received: from (emmanuel@localhost) by foobar.pps.jussieu.fr (8.11.0/jtpda-5.3.2) id f6ODcVF23595 for caml-list@inria.fr; Tue, 24 Jul 2001 15:38:31 +0200 Date: Tue, 24 Jul 2001 15:38:31 +0200 From: Emmanuel.Chailloux@pps.jussieu.fr (Emmanuel Chailloux) Message-Id: <200107241338.f6ODcVF23595@foobar.pps.jussieu.fr> To: caml-list@inria.fr Subject: [Caml-list] loading files in toplevel Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hello, For on-line applications, I want to write a function load : string -> unit which loads ml files in the O'Caml toplevel. For example : let choose x = if x < 0 then load "f1.ml" else load "f2.ml";; with f1.ml : let f1_succ x = x + 1;; and f2.ml : let f2_succ x = x + 1;; My first try was : let load file = Topdirs.dir_use Format.std_formatter file;; # choose 1;; ==> val f2_succ : int -> int = - : unit = () # choose (-1);; ==> val f1_succ : int -> int = - : unit = () BUT I can't acces to the global symbol f1_succ : # f1_succ;; ==> Unbound value f1_succ This symbol belongs to the toplevel environment : # Toploop.getvalue "f1_succ";; ==> - : Obj.t = And this is the good definition : # ( (Obj.obj (Toploop.getvalue "f1_succ")) : int -> int) 1;; ==> - : int = 2 When I trace the function "Toploop.execute_phrase" : # #trace Toploop.execute_phrase;; ==> Toploop.execute_phrase is now traced. the trace output is visible when I use my function "load" but not when I use the directive "#use". # load "f1.ml";; Toploop.execute_phrase <-- true Toploop.execute_phrase --> Toploop.execute_phrase* <-- Toploop.execute_phrase* --> Toploop.execute_phrase** <-- val f1_succ : int -> int = Toploop.execute_phrase** --> true - : unit = () # f1_succ;; Unbound value f1_succ # #use "f1.ml";; val f1_succ : int -> int = # f1_succ;; - : int -> int = When I read the files toplevel/toploop.ml and toplevel/topdirs.ml from the distribution (3.01) I don't understand why the directive "#use" doesn't call Toploop.execute_phrase. Is there a special mode for the directives? Have you any idea? Best regards... Emmanuel... ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr