From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id UAA25002 for caml-redistribution; Mon, 29 Mar 1999 20:05:00 +0200 (MET DST) 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 SAA06319 for ; Mon, 29 Mar 1999 18:32:16 +0200 (MET DST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.8.7/8.8.7) with ESMTP id SAA15841; Mon, 29 Mar 1999 18:31:49 +0200 (MET DST) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA10178; Mon, 29 Mar 1999 18:31:50 +0200 (MET DST) Message-ID: <19990329183150.61773@pauillac.inria.fr> Date: Mon, 29 Mar 1999 18:31:50 +0200 From: Xavier Leroy To: John Prevost , caml-list@inria.fr Subject: Re: another approach to sprintf (Re: ocaml 2.02 bug: curried printf) References: <19990312160017.60444@pauillac.inria.fr> <19990319174720-10695P.sumii@harp.is.s.u-tokyo.ac.jp> <19990323171753.17334@pauillac.inria.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.89.1 In-Reply-To: ; from John Prevost on Wed, Mar 24, 1999 at 02:37:53PM -0500 Sender: weis > It does, however, mean that people can extend the set of patterns that > can be used in printf in a more palatable way than the %a mechanism. > Especially with neat things like Danvy's "lis" combinator. This is a good point. > It also allows me to take two formats and concatenate them, like this: > let foo = int $ lit " " $ int $ string > let bar = lis int $ lit "!" > let zum = foo $ bar > which you can't do with O'Caml's format strings. You almost can. The following definition works as long as you don't have %a and %t escapes in your format strings: let (^^) (s1 : ('a, 'b, 'c) format) (s2 : ('c, 'b, 'd) format) = (Obj.magic (Obj.magic s1 ^ Obj.magic s2) : ('a, 'b, 'd) format) If you have occurrences of %a or %t in s1, the typing becomes wrong. This could be fixed by adding a fourth type parameter to the "format" type constructor, but I agree this is getting really complicated. - Xavier Leroy