Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
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':

  http://www.brics.dk/RS/98/12/

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
Francois.Pottier@inria.fr
http://pauillac.inria.fr/~fpottier/
-------------------
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