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] 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 Archives:
Bug reports: FAQ:
Beginner's list: