[
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: | 2006-08-06 (23:47) |
From: | Christophe TROESTLER <Christophe.Troestler@u...> |
Subject: | format polymorphism |
Hi, Could someone tell me why, say "%s", is of type 'a. (string -> 'b, 'a, 'b) format instead of 'a 'b. (string -> 'b, 'a, 'b) format I am asking this because if one wants to use the same format string both for reading and printing in a given function, one needs the latter type: type 'a fmt = { fmt: 'b 'c. ('a,'b,'c) format } fun (s: _ fmt) -> Printf.printf s.fmt, Scanf.sscanf "string" s.fm However, I cannot instantiate the type [_ fmt]. This is in contrast with let s = ("%s": (_,_,_) format) in Printf.printf s, Scanf.sscanf "string" s which works as intended. I think this may have been discussed before; I just can't remember the reason. Also, is there a safe way of using Obj.magic to make it work ? Regards, ChriS