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 UAA13339; Fri, 15 Oct 2004 20:52:08 +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 UAA13337 for ; Fri, 15 Oct 2004 20:52:07 +0200 (MET DST) From: pad@ryxa.irisa.fr Received: from ryxa.irisa.fr (ryxa.irisa.fr [131.254.50.45]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id i9FIq7HO007511 for ; Fri, 15 Oct 2004 20:52:07 +0200 Received: (from pad@localhost) by ryxa.irisa.fr (8.11.6/8.11.6) id i9FIq6W19115; Fri, 15 Oct 2004 20:52:06 +0200 To: "Nicolas Cannasse" Cc: , Subject: Re: [Caml-list] a generic print (ugly hack) Reply-To: padiolea@irisa.fr References: <200410151657.i9FGvqt18876@ryxa.irisa.fr> <001501c4b2db$400492c0$0100a8c0@warp> Date: 15 Oct 2004 20:52:06 +0200 In-Reply-To: <001501c4b2db$400492c0$0100a8c0@warp> Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Miltered: at concorde with ID 41701C57.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 generic:01 cannasse:01 warplayer:01 ocamlopt:01 generic:01 ocamlmktop:01 calc:01 runtime:01 runtime:01 dumped:01 lacks:01 camlp:01 camlp:01 uglier:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk "Nicolas Cannasse" writes: > I was thinking doing the same some times ago, but without relying on > toplevel (which stucks you to bytecode). I am not stuck to bytecode. the main program can be compiled to native code. I can also do: ocamlopt unix.cmxa str.cmxa generic_print.ml -o test_generic ocamlmktop -o calc.top unix.cma str.cma generic_print.ml > The idea was to be able to load CMI at runtime, and extract type > informations from it in order to correctly print and match types (this is > already what's doing ODLL with functions). It's quite a work and I didn't > finished it. CMI contains *exact* types informations which are not present > at runtime, but not structured in a convenient way for printing or matching > since they're directly dumped from the compiler type representation. But > once done, this would include some dynamism that ocaml lacks when > interacting with outter world (serialization for example). I've coded too in a more cleaner way a trick to achieve the same kind of result (a generic print) by relying on camlp4. I auto-generate string_of_.... function for each type (by doing an induction over the AST of the type definition via camlp4). It was cleaner. But i tend to prefer this uglier version :) > > Nicolas Cannasse ------------------- 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