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 OAA22991 for caml-redistribution; Thu, 25 Mar 1999 14:09:23 +0100 (MET) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id UAA19788 for ; Wed, 24 Mar 1999 20:38:19 +0100 (MET) Received: from zarya.maya.com (zarya.maya.com [192.70.254.128]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id UAA21772 for ; Wed, 24 Mar 1999 20:38:09 +0100 (MET) Received: (from prevost@localhost) by zarya.maya.com (8.8.7/8.8.7) id OAA18033; Wed, 24 Mar 1999 14:37:53 -0500 Sender: weis To: 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 From: John Prevost Date: 24 Mar 1999 14:37:53 -0500 In-Reply-To: Xavier Leroy's message of "Tue, 23 Mar 1999 17:17:53 +0100" Message-ID: User-Agent: Gnus/5.07008 (Pterodactyl Gnus v0.80) Emacs/20.3.92 Xavier Leroy writes: > It's a cute trick. One drawback is that the format is not a character > string, but needs to be expressed using special functions and infix > operators. On the other hand, it doesn't need the special > typechecking rules for format strings that we have in OCaml. > > With this special typechecking rules, I don't think Danvy's "partially > evaluated" printf is any safer than OCaml's "interpreted" printf. > > Also, it doesn't solve (nor makes any worse) the issues with partial > application of printf and friends that we discussed before. 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. 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. (I tried to hack something to do this once, using Obj.magic as the Printf module does. I wasn't able to come up with anything, but I may be able to now that I've had more experience looking at things like Danvy's printf.) John.