From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id VAA03950; Fri, 26 Sep 2003 21: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 VAA08298 for ; Fri, 26 Sep 2003 21:04:59 +0200 (MET DST) Received: from nef.ens.fr (nef.ens.fr [129.199.96.32]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h8QJ4wH03807 for ; Fri, 26 Sep 2003 21:04:58 +0200 (MET DST) Received: from clipper.ens.fr (clipper-gw.ens.fr [129.199.1.22]) by nef.ens.fr (8.12.10/1.01.28121999) with ESMTP id h8QJ4lv1013489 ; Fri, 26 Sep 2003 21:04:50 +0200 (CEST) Received: from localhost (frisch@localhost) by clipper.ens.fr (8.12.3/jb-1.1) id h8QJ4i4Z007277 ; Fri, 26 Sep 2003 21:04:44 +0200 (MET DST) X-Authentication-Warning: clipper.ens.fr: frisch owned process doing -bs Date: Fri, 26 Sep 2003 21:04:44 +0200 (MET DST) From: Alain.Frisch@ens.fr X-X-Sender: frisch@clipper.ens.fr Reply-To: Alain.Frisch@ens.fr To: Richard Jones cc: caml-list@inria.fr Subject: Re: [Caml-list] Printf question In-Reply-To: <20030926180248.GA14053@redhat.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-milter (http://amavis.org/) X-Loop: caml-list@inria.fr X-Spam: no; 0.00; alain:01 frisch:01 caml-list:01 printf:01 printf:01 placeholder:01 expander:01 camlp:01 scanf:01 expander:01 alain:01 compiler:01 handles:01 sep:01 modules:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Fri, 26 Sep 2003, Richard Jones wrote: > I want to write a function which is a bit like Printf.printf, but > handles the %s placeholder differently. It needs to do SQL-style > escaping, eg: > > my_printf "The string: %s" "string with 'quotes'" If you're ready to write <:my_printf "string with 'quotes'" instead, you can write your own quotation expander with Camlp4 and implement the behavior you want. Mmmh, a re-implementation of the Printf and Format modules with this technique would be nice. And also for Scanf (with a pattern quotation expander?). Yes, the typing of the printf functions are magic, and their implementation also. You cannot adapt their behavior without hacking the compiler and using the Obj module. -- Alain ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners