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 XAA13376; Mon, 9 Sep 2002 23:16:05 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id XAA14031 for caml-list@pauillac.inria.fr; Mon, 9 Sep 2002 23:16:05 +0200 (MET DST) 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 WAA13150 for ; Mon, 9 Sep 2002 22:55:05 +0200 (MET DST) Received: from laurelin.dementia.org ([208.167.88.73]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g89Kt4100462 for ; Mon, 9 Sep 2002 22:55:04 +0200 (MET DST) Received: by laurelin.dementia.org (Postfix, from userid 1001) id 0E9F670D2; Mon, 9 Sep 2002 16:55:37 -0400 (EDT) To: Lukasz Lew Cc: John Prevost , caml-list@inria.fr Subject: Re: [Caml-list] Does this function exist? References: From: John Prevost Date: 09 Sep 2002 16:55:36 -0400 (87.194 UMT) In-Reply-To: Message-ID: <86bs76c27r.fsf@laurelin.dementia.org> User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk >>>>> "ll" == Lukasz Lew writes: ll> OK, so I want just "[3; 3]", (no type information), Doesn't matter--you still need type information. Otherwise, you'll get things like: type foo = A | B | C print [A; B; C] outputs: [0; 1; 2] or print ["a"; "b"; "c"] outputs: [; ; ] Since the runtime can't tell the difference between integers and abstract sum types in the first case and can't tell what a pointer is pointing to in the second case. Take a look at what you can see in the O'Caml debugger--in some cases it can tell you the values of things. In many cases, you're in a polymorphioc function and all it says is "" for a value, because it doesn't know how to display the value. Here's an example of that: test.ml ------------------------------------------------------------------------ let rec map f = function | [] -> [] | h::t -> (f h)::(map f t) type t = A | B | C | D | E let i1 = [1; 2; 3; 4; 5] let i2 = [A; B; C; D; E] let i3 = ["a"; "b"; "c"] let o1 = map (fun x -> x) i1 let o2 = map (fun x -> x) i2 let o3 = map (fun x -> x) i3 ------------------------------------------------------------------------ $ ocamldebug a.out Objective Caml Debugger version 3.04 (ocd) run Loading program... done. Time : 82 Program exit. (ocd) break Test.map Breakpoint 1 at 5008 : file Test, line 1 column 13 (ocd) goto 0 Time : 0 Beginning of program. (ocd) run Time : 12 - pc : 5040 - module Test Breakpoint : 1 3 | h::t -> <|b|>(f h)::(map f t) (ocd) print h h : 'a = (ocd) print t t : 'a list = [; ; ; ] (ocd) bt #0 Pc : 5040 Test char 50 #1 Pc : 5196 Test char 200 (ocd) up #1 Pc : 5196 Test char 200 11 let o1 = map (fun x -> x) i1<|a|> (ocd) print i1 i1 : int list = [1; 2; 3; 4; 5] Here we see that when we're inside the polymorphic function, the type information is lost (even though we're in debugging mode.) Only by going up the stack to a point where the type of the value is known can we learn anything. John. ------------------- 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