Browse thread
Scanf question
- Sasha Rush
[
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: | Sasha Rush <rush@f...> |
| Subject: | Scanf question |
Hi all,
I'm curious about the asymmetry between printf and scanf.
I like the modularity I can get by user defined printers, i.e.
module Foo =
struct
type t = int
let print ppf = fprintf "%d"
end
printf "My %a" Foo.print some_foo
But how do I get the same abstraction with scanf?
let id a = a
module Foo =
struct
type t = int
let read buf = bscanf "%d" id
end
(*Seemed natural*)
let some_foo = bscanf "My %a" Foo.read id
Thanks,
/Sasha