Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] a generic print (ugly hack)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: pad@r...
Subject: Re: [Caml-list] a generic print (ugly hack)
"Nicolas Cannasse" <warplayer@free.fr> 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