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 WAA25900; Tue, 30 Sep 2003 22:53:14 +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 WAA29963 for ; Tue, 30 Sep 2003 22:53:12 +0200 (MET DST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h8UKqaH17957; Tue, 30 Sep 2003 22:52:36 +0200 (MET DST) Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id WAA26950; Tue, 30 Sep 2003 22:52:35 +0200 (MET DST) From: Pierre Weis Message-Id: <200309302052.WAA26950@pauillac.inria.fr> Subject: Re: [Caml-list] Printf question In-Reply-To: <1064927948.8999.18.camel@pelican> from skaller at "Sep 30, 103 11:19:08 pm" To: skaller@ozemail.com.au Date: Tue, 30 Sep 2003 22:52:35 +0200 (MET DST) Cc: pierre.weis@inria.fr, rich@annexia.org, caml-list@inria.fr X-Mailer: ELM [version 2.4ME+ PL28 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Loop: caml-list@inria.fr X-Spam: no; 0.00; pierre:01 weis:01 pierre:01 weis:01 caml-list:01 printf:01 well-typed:01 pretty-print:01 textual:01 pretty-print:01 typechecked:01 statically:01 printf:01 compiler:01 cristal:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > > 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. Thank you very much for the clarification. So the problem is the generation of programs (SQL requests) that should be well-typed (for SQL). The normal Caml approach to this kind of problems is to generate a tree like structure with constructors (the AST of the request) and then to pretty-print this tree to textual form. This way the pretty-print phase is simple and may easily generate syntactically correct requests. Hence, we end with the problem of generating sound trees for the requests. The first benefit of this two stages approach is that the constructors are typed, thus their applications is typechecked and statically eliminate the generation of trivially wrong programs (wrong requests). If this checks (provided for free by the Caml compiler) are not sufficient to obtain the expected safety, you probably need to write an extra static analysis pass on the generated tree to detect the remainding errors. Mmm, this is interesting, but this is no more a printf problem, and indeed far from a simple programming question ... Pierre Weis INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis/ ------------------- 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