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
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Luca Pascali <luca@b...>
Subject: Re: [Caml-list] string_of_polymorphic
I resend the message, because I sent it only to Jon

Jon Harrop wrote:

> On Monday 03 January 2005 09:52, Luca Pascali wrote:
>> As the subject says, my aim is to write a function that is able to
>> covert into a string a generic polymorphic constructor, or at least its
>> name, without using patter matching.
> Why do you want to do this?
Logging purposes, Error handling and so on.
I have a function that accept some polymorphic constructors as input 
type, and I want to log what is arrived before possibly without writing 
everytime a pattern matching ad-hoc, or raising an exception, I'd like 
to attach the constructor that raised the exception.

>> ...
>> Thanks in advance to anyone for hints, or links, or wathever help you
>> can give me.
> I think the run-time representation of a polymorphic variants' value 
> is a hash of its name and, therefore, cannot be mapped back onto a 
> string in general. There may be something else you can do specifically 
> for the top-level but I can't think what...
> Cheers,
> Jon.
I don't know.
Polymorphic constructors survive to the marshalling-unmarshalling.
In the marshalled string, there is a representation of their name. 
That's why I thought there was a method to get their names into a function.
I think that if Obj is strongly not recommended, analizing a marshalled 
string has to be avoided, so I was looking for other ways.


Luca Pascali
Baretta DE&IT
A division of Baretta SRL

tel. 02 370 111 55
fax. 02 370 111 54

Our technology: