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 UAA03774; Mon, 29 Sep 2003 20:13:51 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 UAA27126 for ; Mon, 29 Sep 2003 20:13:46 +0200 (MET DST) Received: from aomori.annexia.org (annexia.force9.co.uk [212.56.101.183]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h8TIDd512949; Mon, 29 Sep 2003 20:13:40 +0200 (MET DST) Received: from rich by aomori.annexia.org with local (Exim 3.36 #1 (Debian)) id 1A42Wb-0002uK-00; Mon, 29 Sep 2003 19:13:33 +0100 Date: Mon, 29 Sep 2003 19:13:33 +0100 To: Pierre Weis Cc: caml-list@inria.fr Subject: Re: [Caml-list] Printf question Message-ID: <20030929181332.GA10941@redhat.com> References: <20030927091408.GB14604@redhat.com> <200309291642.SAA08681@pauillac.inria.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200309291642.SAA08681@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 typechecked:01 statically:01 fmt:01 printf:01 fmt:01 val:01 sth:99 salary:01 emp:99 val:01 sth:99 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Mon, Sep 29, 2003 at 06:42:09PM +0200, Pierre Weis wrote: > I'm pretty sure that format string contsnats are typechecked > statically with the usual typechecker resolution mechanism (a bit more > complex, but no more magic than the typechecking of the -> type > constructor). > > So why not using format values directly ? > > For instance: > > # let prepare fmt = Printf.printf fmt;; > val prepare : ('a, out_channel, unit) format -> 'a = > > # let sth x = > prepare "select salary from emp where id = %d and name = %s" x;; > val sth : int -> string -> unit = > > # sth 1 "Jones" > select salary from emp where id = 1 and name = Jones- : unit = () > > This is fully statically typechecked as required. > > Or may be I'm missing something ? I guess the problem is that I want my own interpretation for %s. It has to do SQL-quoting, otherwise you could write: # sth 1 "'Jones'; drop database 'company'";; select salary from emp where id = 1 and name = 'Jones'; drop database 'company'- : unit = () (Or worse ...?) 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. NET::FTPSERVER is a full-featured, secure, configurable, database-backed FTP server written in Perl: http://www.annexia.org/freeware/netftpserver/ ------------------- 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