From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr 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 9399CBC29 for ; Mon, 7 Aug 2006 01:47:37 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id k76NlbDl017089 for ; Mon, 7 Aug 2006 01:47:37 +0200 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 BAA25015 for ; Mon, 7 Aug 2006 01:47:36 +0200 (MET DST) Received: from hedwig1.umh.ac.be (hedwig2.umh.ac.be [193.190.193.73]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id k76NlaDc017070 for ; Mon, 7 Aug 2006 01:47:36 +0200 Received: from poincare.swapping.umh.ac.be (pri-010.umh.ac.be [10.101.0.10]) by hedwig1.umh.ac.be (8.13.6/8.13.6) with ESMTP id k76NnxWR569444; Mon, 7 Aug 2006 01:50:00 +0200 Received: from [127.0.0.1] (helo=localhost) by poincare.swapping.umh.ac.be with esmtp (Exim 4.62) (envelope-from ) id 1G9s7N-0006nh-CR; Mon, 07 Aug 2006 01:33:13 +0200 Date: Mon, 07 Aug 2006 01:33:12 +0200 (CEST) Message-Id: <20060807.013312.243185382.Christophe.Troestler@umh.ac.be> To: "O'Caml Mailing List" Subject: format polymorphism From: Christophe TROESTLER X-Face: #2fb%mPx>rRL@4ff~TVgZ"<[:,oL"`TUEGK/[8/qb58~C>jR(x4A+v/n)7BgpEtIph_neoLKJBq0JBY9:}8v|j Organization: Universite de Mons-Hainaut (http://math.umh.ac.be/an/) X-Spook: bluebird DES AIEWS South Africa MDA Ft. Bragg 9705 Samford Road world domination Sears Tower unclassified X-Blessing: Om Ah Hum Vajra Guru Pema Siddhi Hum X-Operating-System: Debian GNU/Linux (http://www.debian.org/) X-Mailer: Mew version 4.2.52 on Emacs 22.0.50 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.1 (www dot roaringpenguin dot com slash mimedefang) X-Miltered: at concorde with ID 44D67F99.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 44D67F98.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; polymorphism:01 christophe:01 troestler:01 christophe:01 troestler:01 umh:01 fmt:01 fmt:01 printf:01 printf:01 scanf:01 sscanf:01 scanf:01 sscanf:01 contrast:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 Hi, Could someone tell me why, say "%s", is of type 'a. (string -> 'b, 'a, 'b) format instead of 'a 'b. (string -> 'b, 'a, 'b) format I am asking this because if one wants to use the same format string both for reading and printing in a given function, one needs the latter type: type 'a fmt = { fmt: 'b 'c. ('a,'b,'c) format } fun (s: _ fmt) -> Printf.printf s.fmt, Scanf.sscanf "string" s.fm However, I cannot instantiate the type [_ fmt]. This is in contrast with let s = ("%s": (_,_,_) format) in Printf.printf s, Scanf.sscanf "string" s which works as intended. I think this may have been discussed before; I just can't remember the reason. Also, is there a safe way of using Obj.magic to make it work ? Regards, ChriS