English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Constructors are not functions
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2009-10-06 (15:24)
From: Richard Jones <rich@a...>
Subject: Re: [Caml-list] Constructors are not functions
On Tue, Oct 06, 2009 at 03:04:02PM +0100, David Allsopp wrote:
> That's not the case at all - there'd be no reason not to interpret
> [bar] as [fun x y -> Bar(x, y)] for [Bar of int * int]. What would be
> hairy in camlp4 would be having to read .cmi files to deal with types
> defined outside your source file, but that's still not impossible...

The devil is in the details.  I had a look at this, and because you
don't have access to the command line (eg. -I parameters) you can't
easily find the *.cmi files you need.  That is assuming it was easy to
parse the command line (hard to do it reliably) or that you could look
inside *.cmi files (the format is undocumented and release-specific).

It would be so nice to have a macro tool which was aware of types, but
that tool isn't camlp4.  There are probably theoretical problems with
this, but having a "give_me_the_type_of (ocaml_subexpression)"
function would be awesome indeed.


Richard Jones
Red Hat