Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] scanf and %2c
[ 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] scanf and %2c
Bonjour Alan,

> As I needed to parse some string representing time (of the form hh:mm), 
[...]

Welcome to the dates and time users' camp! Too bad that there is no
support for that kind of stuff in our favorite language :(

> So shouldn't there be a warning (or an error) when using a size field 
> with chars ?
> 
> Alan

We must be a bit more precise than that: we should check that the size
field is positive and lesser or equal than 1.

In effect:

- a 0 sized char scanf specification has a special useful meaning (see
Scanf.mli for details): it means ``pick'' the current character
without reading it (in order to test its value and decide what to do
next),

- a 1 sized char scanf specification seems to be harmless.

I will try to had a static check in the type-checker (the usual Caml
way), orelse a runtime failure in Scanf (the usual way of more
conventional programming languages).

Amicalement,

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