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: Alain.Frisch@e...
Subject: Re: [Caml-list] Printf question
On Fri, 26 Sep 2003, Richard Jones wrote:

> I want to write a function which is a bit like Printf.printf, but
> handles the %s placeholder differently. It needs to do SQL-style
> escaping, eg:
>
> 	my_printf "The string: %s" "string with 'quotes'"

If you're ready to write

  <:my_printf<The string: %s> "string with 'quotes'"

instead, you can write your own quotation expander with Camlp4 and
implement the behavior you want.  Mmmh, a re-implementation of the
Printf and Format modules with this technique would be nice.
And also for Scanf (with a pattern quotation expander?).

Yes, the typing of the printf functions are magic, and their
implementation also. You cannot adapt their behavior without hacking the
compiler and using the Obj module.

-- Alain

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