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 XAA12780; Mon, 29 Sep 2003 23:50:11 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 XAA06437 for ; Mon, 29 Sep 2003 23:50:10 +0200 (MET DST) Received: from aomori.annexia.org (annexia.force9.co.uk [212.56.101.183]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h8TLo9H08132 for ; Mon, 29 Sep 2003 23:50:09 +0200 (MET DST) Received: from rich by aomori.annexia.org with local (Exim 3.36 #1 (Debian)) id 1A45uD-0003vH-00 for ; Mon, 29 Sep 2003 22:50:09 +0100 Date: Mon, 29 Sep 2003 22:50:08 +0100 Cc: caml-list@inria.fr Subject: Re: [Caml-list] Printf question Message-ID: <20030929215008.GA15057@redhat.com> References: <20030929181332.GA10941@redhat.com> <200309291957.VAA09271@pauillac.inria.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200309291957.VAA09271@pauillac.inria.fr> User-Agent: Mutt/1.5.4i From: Richard Jones X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 printf:01 pierre:01 weis:01 quoting:01 printf:01 fprintf:01 val:01 quoting:01 sth:99 sth:99 salary:01 emp:99 val:01 salary:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Mon, Sep 29, 2003 at 09:57:19PM +0200, Pierre Weis wrote: > Hence, I think you are seeking for the %a conversion. For instance, > defining a quotation function for SQL as in > > # let sql_quoting oc = Printf.fprintf oc "'%s'";; > val sql_quoting : out_channel -> string -> unit = > > You can define sth with a %a conversion to apply quoting on the fly: > > # let sth x = > prepare "select salary from emp where id = %d and name = %a" x;; > val sth : int -> (out_channel -> 'a -> unit) -> 'a -> unit = > > # sth 1 sql_quoting "Jones";; > select salary from emp where id = 1 and name = 'Jones'- : unit = () > > Still fully type-checked! Sounds better, no ? Hmmm ... but as I explained earlier, that's really not type safe at all. Rich. -- Richard Jones. http://www.annexia.org/ http://freshmeat.net/users/rwmj Merjis Ltd. http://www.merjis.com/ - all your business data are belong to you. C2LIB is a library of basic Perl/STL-like types for C. Vectors, hashes, trees, string funcs, pool allocator: http://www.annexia.org/freeware/c2lib/ ------------------- 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