Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Using -dtypes output in conjunction with a preprocessor
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Michal Moskal <malekith@p...>
Subject: Re: [Caml-list] Using -dtypes output in conjunction with a preprocessor
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