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

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


Pierre Weis

INRIA, Projet Cristal,,

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: