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 PAA09294; Tue, 30 Sep 2003 15:19:24 +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 PAA14508 for ; Tue, 30 Sep 2003 15:19:22 +0200 (MET DST) Received: from mail2.tpgi.com.au (mail.tpgi.com.au [203.12.160.58]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h8UDJJ503505; Tue, 30 Sep 2003 15:19:20 +0200 (MET DST) Received: from 203-219-16-71-syd-ts21-2600.tpgi.com.au (203-219-16-71-syd-ts21-2600.tpgi.com.au [203.219.16.71]) by mail2.tpgi.com.au (8.12.10/8.12.10) with ESMTP id h8UDJ9Fv008312; Tue, 30 Sep 2003 23:19:11 +1000 Subject: Re: [Caml-list] Printf question From: skaller Reply-To: skaller@ozemail.com.au To: Pierre Weis Cc: Richard Jones , caml-list@inria.fr In-Reply-To: <200309292236.AAA23653@pauillac.inria.fr> References: <200309292236.AAA23653@pauillac.inria.fr> Content-Type: text/plain Message-Id: <1064927948.8999.18.camel@pelican> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 30 Sep 2003 23:19:08 +1000 Content-Transfer-Encoding: 7bit X-Kaspersky-Antivirus: Passed X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 printf:01 ozemail:01 pierre:01 weis:01 pierre:01 weis:01 quoting:01 printf:01 fprintf:01 val:01 quoting:01 sth:99 sth:99 salary:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Tue, 2003-09-30 at 08:36, Pierre Weis wrote: > > 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. > > What do you mean by ``not type safe at all'' ? > > The common acceptation is ``it could lead to type errors at runtime''. What I think he means is that it isn't type safe with respect to an SQL typing: the Ocaml typing is not 'sound' for SQL in that bogus SQL syntax can be produced by type correct Ocaml: the SQL call can result in an SQL Syntax Error at run time. ------------------- 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