From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id pB99QVSv003429 for ; Fri, 9 Dec 2011 10:26:31 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AiQBANnS4U5KfVI0imdsb2JhbABDqmEIIgEBAQoJDQcSBiGBcgEBAQMBDAYCLAEbDw8DAQsGBQsNLiIBEQEFARwGARIbB4dlCJocCotkgmuERj2IcQIFDIsDYwSUcI1xPYN6 X-IronPort-AV: E=Sophos;i="4.71,325,1320620400"; d="scan'208";a="134683536" Received: from mail-ww0-f52.google.com ([74.125.82.52]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-MD5; 09 Dec 2011 10:26:27 +0100 Received: by wgbdr12 with SMTP id dr12so6289058wgb.9 for ; Fri, 09 Dec 2011 01:26:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=SHIr7WN2BdD4OXtcC+3c/eWus7xLOV80VkEnghJrl38=; b=U50pcRN7b7NwCFJtsnrCV95l0hllmK95GFNIi/35+gK7qVhabzL8iizuUyEwIDSyeM SKjlAXqBME5oRV3Nc+BnuhDOTZQ+/xxq1TQ0Ev3yZaJBk/Vi97+lszj1miClsFb01Ykm QlgTSd/dQ5sVoWYOqrM0eCGUDmHBwnlGgJroA= Received: by 10.180.105.3 with SMTP id gi3mr9784292wib.36.1323422787194; Fri, 09 Dec 2011 01:26:27 -0800 (PST) MIME-Version: 1.0 Received: by 10.227.43.4 with HTTP; Fri, 9 Dec 2011 01:26:06 -0800 (PST) In-Reply-To: <1323415332.3523.34.camel@aurora> References: <1323271707.32238.17.camel@arrakis> <4EDF9AAE.5050604@crans.org> <1323279292.32238.48.camel@arrakis> <4EE0A6C6.8040703@lri.fr> <4EE0FFDE.1050107@ens-lyon.org> <1323415332.3523.34.camel@aurora> From: Gabriel Scherer Date: Fri, 9 Dec 2011 10:26:06 +0100 Message-ID: To: =?ISO-8859-1?Q?J=E9r=E9mie_Dimino?= , caml users Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id pB99QVSv003429 Subject: Re: [Caml-list] Generic printer patch > If think my hack is reasonable too, you just have to replace ocamlc and > ocamlopt (if you already use ocaml 3.12.1) by the new compilers and it > will work. Indeed. It's just that in some cases (eg. you are no expert user and/or use the ocaml binary packages of your distribution) the cost of patching the compiler is quite high, and Std.dump is useful a degraded but work-out-of-the-box solution. On Fri, Dec 9, 2011 at 8:22 AM, Jérémie Dimino wrote: > Le jeudi 08 décembre 2011 à 22:39 +0100, Gabriel Scherer a écrit : >> Of course, the "right" way to print/marshal data without changing the >> language is to build a printer for your type from printer combinators. >> Such combinators are available for example: >> - in Jane Street Core library ( a Sexpable interface in each datatype module ) >> - in Xavier Clerc's Kaputt testing framework : >> http://kaputt.x9c.fr/distrib/api/Utils.html >> >> You can also use metaprogramming (.. camlp4) to generate printer >> functions from datatypes description automatically, using such >> combinators. See: >> - Markus Mottl's 'type-conv': http://hg.ocaml.info/release/type-conv >> - Jeremy Yallop's 'deriving': http://code.google.com/p/deriving/ > > These solutions would be usable only if everybody were using it. Right > now almost nobody use them, and so if you want to print types coming > from external library you still have to write the printer yourself. > >> Of course, printing values magically is still easier: you don't have >> to build the printer yourself, passing subtype printers when >> necessary, etc. I think Std.dump is reasonable for quick hacks or >> debugging usage. > > If think my hack is reasonable too, you just have to replace ocamlc and > ocamlopt (if you already use ocaml 3.12.1) by the new compilers and it > will work. > > Of course don't use it in production code ;-) > > Cheers, > > -- > Jérémie >