Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] sscanf help
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Pierre Weis <pierre.weis@i...>
Subject: Re: [Caml-list] sscanf help
> Hello,
> I am having hardtime dealing with sscanf and fscanf fucntion. I am actually 
> converting code from C to OCAML. The functions uses multiple sscanf 
> fucntions. I have no clue how to deal with this. Can anyone please help me 
> out?

[...]

The Caml's sscanf and fscanf functions are fully documented and are
easier to use and much more powerful than their C counterparts; so,
unless the documentation is unclear (and then please report it to me),
I think your problem is more related to C programming than to some
O'Caml specific scanf difficulties.

In effect, the C function you gave and have to translate to Caml looks
extremely stateful and imperative style in spirit, while our
programming language and its scanf facility are functional (or
stateless). So, even if it is possible to mimic the C program in Caml,
the resulting program is likely to be inelegant and contrived by an
unatural one-to-one translation.

In conclusion, you had better to understand the specification of the C
parsing function and then reimplement it into a (simpler) functional
Caml program.

Hope this helps,

Pierre Weis

INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis/


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