From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id AD393BB81 for ; Mon, 3 Jan 2005 12:01:17 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j03B1HPJ023157 for ; Mon, 3 Jan 2005 12:01:17 +0100 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id MAA30035 for ; Mon, 3 Jan 2005 12:01:16 +0100 (MET) Received: from smtp004.mail.ukl.yahoo.com (smtp004.mail.ukl.yahoo.com [217.12.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with SMTP id j03B1GjY023152 for ; Mon, 3 Jan 2005 12:01:16 +0100 Received: from unknown (HELO ?10.0.0.115?) (pasckosky@213.255.109.130 with plain) by smtp004.mail.ukl.yahoo.com with SMTP; 3 Jan 2005 11:01:16 -0000 Message-ID: <41D925FB.6010509@barettadeit.com> Date: Mon, 03 Jan 2005 12:01:15 +0100 From: Luca Pascali User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20041007 Debian/1.7.3-5 X-Accept-Language: en MIME-Version: 1.0 To: caml-list@inria.fr Subject: Re: [Caml-list] string_of_polymorphic References: <41D915E0.4030701@yahoo.it> <200501031018.47703.jon@jdh30.plus.com> In-Reply-To: <200501031018.47703.jon@jdh30.plus.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 41D925FD.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 41D925FC.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 wrote:01 wrote:01 constructors:01 ad-hoc:01 run-time:01 hash:01 cheers:01 constructors:01 avoided:01 baretta:01 baretta:01 covert:98 ...:98 ...:98 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.0 X-Spam-Level: I resend the message, because I sent it only to Jon Sorry. 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 -- ********************************************************************* Luca Pascali luca@barettadeit.com asxcaml-guru@barettadeit.com http://www.barettadeit.com/ Baretta DE&IT A division of Baretta SRL tel. 02 370 111 55 fax. 02 370 111 54 Our technology: http://www.asxcaml.org/ http://www.freerp.org/