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 LAA11993; Fri, 22 Aug 2003 11:06:13 +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 LAA32163 for ; Fri, 22 Aug 2003 11:06:12 +0200 (MET DST) Received: from ep09.kernel.pl (ep09.kernel.pl [212.87.11.162]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h7M96Bf17606 for ; Fri, 22 Aug 2003 11:06:11 +0200 (MET DST) Received: (qmail 9471 invoked by uid 566); 22 Aug 2003 09:06:03 -0000 Date: Fri, 22 Aug 2003 11:05:18 +0200 From: Michal Moskal To: art yerkes Cc: caml-list@inria.fr Subject: Re: [Caml-list] Using -dtypes output in conjunction with a preprocessor Message-ID: <20030822090518.GA4616@roke.freak> Mail-Followup-To: art yerkes , caml-list@inria.fr References: <20030822023949.16fae994.ayerkes@speakeasy.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030822023949.16fae994.ayerkes@speakeasy.net> User-Agent: Mutt/1.4.1i X-PGP-Fingerprint: CF89 1B14 11BE 1CC9 2CA3 7497 5E32 69B4 BC71 B4C2 X-AntiVirus: scanned for viruses by AMaViS 0.2.1 (http://amavis.org/) X-Loop: caml-list@inria.fr X-Spam: no; 0.00; michal:01 moskal:01 malekith:01 pld-linux:01 caml-list:01 yerkes:01 ocamlc:01 camlp:01 marshalling:01 endline:01 swig:01 foo:01 endline:01 foo:01 baz:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Fri, Aug 22, 2003 at 02:39:49AM -0500, art yerkes wrote: > While I know it's not really intended for this, I've been giving some thought > to streamlining SWIG's Ocaml support. To this end, I notice that -dtypes > has been added to ocamlc in order to support type browsing in emacs. > > What I'm interested in finding out is if this output is expected to be stable, > or if there is another way to get this sort of deep type information from a > source file. I intend to use this information as hints to a camlp4 module > that will recognize and rewrite references to C++ externals in order to emulate > C++ style overloading. > > As far as I can see, I will need the ocaml compiler to tell me what type is > expected for a certain application, Expected type? Hmm... > then insert marshalling code that produces > and consumes the types indicated in the hint. > > For example, I might produce: > > let _ = print_endline > (string_of_int > (get_int (__swig__wrapped_foo (C_list [(C_int a) (C_int b)])) > > from: > > let _ = print_endline (string_of_int (foo 1 2)) > > Given that the detected type of foo will be "int -> int -> int" > > Is using the -dtypes output the best way to get the right info? How about: let f x y = foo x y and: let g x y = let baz = foo x y in let qux = foo baz baz in x + 1 You probably should find out how type inference works. -- : Michal Moskal :: http://www.kernel.pl/~malekith : GCS {C,UL}++++$ a? !tv : When in doubt, use brute force. -- Ken Thompson : {E-,w}-- {b++,e}>+++ h ------------------- 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