Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Printf question
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: skaller <skaller@o...>
Subject: Re: [Caml-list] Printf question
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 = <fun>
> > > 
> > > 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 = <fun>
> > > 
> > > # 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