From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: weis Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id PAA22165 for caml-redistribution@pauillac.inria.fr; Thu, 27 Jan 2000 15:06:53 +0100 (MET) Resent-Message-Id: <200001271406.PAA22165@pauillac.inria.fr> 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 UAA15453 for ; Wed, 26 Jan 2000 20:38:15 +0100 (MET) Received: from micutzu.loria.fr (micutzu.loria.fr [152.81.7.80]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id UAA07003 for ; Wed, 26 Jan 2000 20:38:14 +0100 (MET) Received: (from sorin@localhost) by micutzu.loria.fr (8.9.3/8.9.3) id UAA02941; Wed, 26 Jan 2000 20:38:06 +0100 From: Sorin Stratulat MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Wed, 26 Jan 2000 20:38:03 +0100 (CET) To: caml-list@inria.fr Subject: - WHY ? X-Mailer: VM 6.43 under 20.4 "Emerald" XEmacs Lucid Message-ID: <14479.17696.496132.380433@micutzu.loria.fr> Reply-To: stratula@loria.fr Resent-From: weis@pauillac.inria.fr Resent-Date: Thu, 27 Jan 2000 15:06:53 +0100 Resent-To: caml-redistribution@pauillac.inria.fr Hello ! I started to debug large OCaml code and apparently the only acceptable solution to do this is to use the debugger. Unfortunately, I found difficulties to convince the debugger to print objects. Let's take a simple example (took from the manual): (***** File essai.ml *******) class point = object val mutable x = 0 method get_x = x method move d = x <- x + d end;; let my_p = new point;; (****************************) In order to print the value x of my_p, I separately defined a printer function as (***** File essai_printer.ml *******) open Format let my_print_point s = open_box 0; print_string ("The point is situated at" ^ string_of_int (s#get_x)); print_space (); close_box (); print_newline () ;; (****************************) let my_print_point s = open_box 0; print_string ("The point is situated at" ^ string_of_int (s#get_x)); print_space (); close_box (); print_newline () ;; Here are the steps I followed: 1. Compile essai.ml and essai_printer.ml ocamlc -c -g essai.ml ocamlc -c -g essai_printer.ml 2. Create the executable file "essai" ocamlc -custom -g -o essai essai.cmo 3. Launch the debugger on the file "essai" 4. load the printer (I show also the answer of the debugger) (ocd) load_printer "essai_printer.cmo" File ./essai_printer.cmo loaded 5. install the printer function my_print_point (ocd) install_printer Essai_printer.my_print_point 6. ....put a breakpoint immediately after the definition of my_p 7. print my_p (ocd) p my_p my_p : point = ------------------------------------------------------------------ Can somebody tell me the "solution" to print the value "x" of my_p ? Thank you, Sorin French version: Bonjour ! Je suis en train de deboguer de gros fichiers en OCaml et je suis contraint d'utiliser le debogueur. Malheureusement, je n'arrive pas a afficher des objets. Voici un tres simple exemple (pris du manuel): (***** File essai.ml *******) class point = object val mutable x = 0 method get_x = x method move d = x <- x + d end;; let my_p = new point;; (****************************) Pour afficher la valeur x de my_p, j'ai defini separement une fonction d'impression (***** File essai_printer.ml *******) open Format let my_print_point s = open_box 0; print_string ("The point is situated at" ^ string_of_int (s#get_x)); print_space (); close_box (); print_newline () ;; (****************************) Les etapes que j'ai suivi sont les suivantes: 1. Compiler essai.ml et essai_printer.ml ocamlc -c -g essai.ml ocamlc -c -g essai_printer.ml 2. Creer le fichier executable "essai": ocamlc -custom -g -o essai essai.cmo 3. Lancer le debogueur sur le fichier "essai": 4. Charger le "printer" (ocd) load_printer "essai_printer.cmo" File ./essai_printer.cmo loaded 5. Installer la fonction d'impression my_print_point (ocd) install_printer Essai_printer.my_print_point 6. ... fixer un breakpoint juste apres la definition de my_p 7. imprimer my_p (ocd) p my_p my_p : point = ------------------------------------------------------------------ Et la question: Quelle est la solution pour imprimer la valeur x de my_p ? Merci d'avance, Sorin -- e-mail : Sorin.Stratulat@loria.fr www : http://www.loria.fr/~stratula Project: PROTHEO Office : A201 | Home: ------ | ------ tel: 03.83.59.30.02 | 1, rue Charles Sadoul LORIA - BP 239 | 54000 Nancy F-54506 VANDOEUVRE-les-NANCY Cedex FRANCE | tel. 06.10.46.49.99