Browse thread
Re: [Caml-list] Pattern matching and strings
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Alessandro Baretta <alex@b...> |
| Subject: | Re: [Caml-list] Pattern matching and strings (and a mini-bug in Scanf) |
Remi VANICAT wrote: > Alessandro Baretta <alex@baretta.com> writes: > > >>Pierre Weis wrote: >> >>>[...] >> >>>I should say that I am reluctant to had a special typing rule for the >>>new specifier you proposed, when "%[\000-\255]" does perfectly the job >>>and does not require any addition to the type-checker nor to the >>>implementation of Scanf. >>>Pierre Weis >> >>Why do you mention the type checker? Is each conversion specifier a >>special case for the type checker? > > > Of course it is : > > # Scanf.scanf "%s %d %i";; > - : (string -> int -> int -> '_a) -> '_a = <fun> > > to type this, the type checker have to look inside the format and find > that %s look for a string, %d and %i an int. > I did not make myself clear. Of course, the type checker has to delve into a format string to figure out how to type Scanf.sscanf "%s %d %i", but that does not mean that "%s %[abc] %[^def]" requires three different "special cases" in the type checker. I haven't read how the typechecker reads format strings, but I would expect that it should only be intersted in the *type* of the conversion specifier, as opposed to how the conversion is implemented. All conversions specifying integers should be treated uniformly by the type checker; by the same standards all conversions specifying strings should be treated in the same way. A "%z" specifier meaning "everything till the end of input" should look no different to the type checker than a "%s" or a "%[abc]". Anyhow, I can live with "%[\000-\255]", but I still think that a "%z" would be a worthy addition. Alex ------------------- 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