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 EAA18967; Fri, 7 May 2004 04:42:44 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id EAA19095 for ; Fri, 7 May 2004 04:42:42 +0200 (MET DST) Received: from glockenspiel.complete.org (glockenspiel.complete.org [69.10.152.57]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i472geEV024345 for ; Fri, 7 May 2004 04:42:41 +0200 Received: from localhost (localhost [127.0.0.1]) by glockenspiel.complete.org (Postfix) with ESMTP id 5159CBD; Thu, 6 May 2004 21:42:44 -0500 (CDT) Received: from glockenspiel.complete.org ([127.0.0.1]) by localhost (glockenspiel [127.0.0.1]) (amavisd-new, port 10025) with ESMTP id 14327-01; Thu, 6 May 2004 21:42:42 -0500 (CDT) Received: by glockenspiel.complete.org (Postfix, from userid 1000) id 8F2F0C5; Thu, 6 May 2004 21:42:42 -0500 (CDT) Date: Thu, 6 May 2004 21:42:42 -0500 From: John Goerzen To: caml-list@inria.fr Subject: [Caml-list] Trouble with Toploop Message-ID: <20040507024242.GA13530@complete.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.5.1+cvs20040105i X-Virus-Scanned: by amavisd-new-20030616-p7 (Debian) at complete.org X-Miltered: at nez-perce with ID 409AF7A0.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; toploop:01 toploop:01 formatter:01 endline:01 endline:01 val:01 val:01 typecore:01 int:01 int:01 toplevel:01 toplevel:01 exception:02 initialize:02 string:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hello, I am having trouble making Toploop.setvalue do the right thing. Here is an example: Toploop.initialize_toplevel_env();; let apv = 5;; Toploop.setvalue "apv" (Obj.repr apv);; let eval txt = let lb = (Lexing.from_string txt) in let phr = !Toploop.parse_toplevel_phrase lb in Toploop.execute_phrase true Format.std_formatter phr;; eval "let add1 x = x +1;;";; eval "add1 2;;";; eval "let y = 42;;";; print_int (Obj.obj (Toploop.getvalue "y"));; print_endline "";; print_int (Obj.obj (Toploop.getvalue "apv"));; print_endline "";; eval "add1 apv;;";; eval "apv;;";; When I run this, I get: val add1 : int -> int = - : int = 3 val y : int = 42 42 5 Fatal error: exception Typecore.Error(_, _) (Note that the eval "apv;;" would give the same error.) So, I get set a value. I can later get it back with getvalue. I can also use getvalue to give me values that were set entirely within the toploop environment. But I cannot use a value I have set with setvalue in any calculation. Any suggestions? -- John Goerzen www.complete.org ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners