English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] How to read three integers from a text-file... ?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-04-29 (06:44)
From: Francois Pottier <francois.pottier@i...>
Subject: Re: [Caml-list] How to read three integers from a text-file... ?

On Wed, Apr 24, 2002 at 11:23:16PM +0200, Tomasz Zielonka wrote:
> 4) Create mechanism dual to printf, but as far as I understand
>    OCaml's printf, this would require extending typechecker.

No, it does not. Check out Olivier Danvy's paper `Functional Unparsing':


It describes a very nice way of programming `printf' within ML's type
system. `scanf' could be handled in a similar way. Furthermore, this approach
yields code that is claimed to be more efficient than O'Caml's current
`printf' implementation (because the overhead of interpreting format strings
is lower). Lastly, it scales up to more expressive format directives, such as
a directive for printing a list.

It might be worth adding a module that implements Danvy-style `printf' and
`scanf' to the standard library. Has anyone written such a module already?
Otherwise, I might consider doing it.

François Pottier
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