Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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" <> 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 -o test_generic
  ocamlmktop -o unix.cma str.cma 

> 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 Archives:
Bug reports: FAQ:
Beginner's list: