Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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: 2003-09-30 (20:53)
From: Pierre Weis <pierre.weis@i...>
Subject: Re: [Caml-list] Printf question
> > 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

 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,,

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: