Browse thread
[Caml-list] kprintf with user formatters
[
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: | 2004-07-16 (16:52) |
From: | Markus Mottl <markus@o...> |
Subject: | Re: [Caml-list] kprintf with user formatters |
On Fri, 16 Jul 2004, Pierre Weis wrote: > No, this is not safe: you break the type system and create buggy > values like that. True, but unit values are not very useful so if the user ignores them (as usual), there won't be any problems. > # let log b fmt = > if b then Printf.printf fmt else > let rec f x = Obj.magic f in f fmt;; > val log : bool -> ('a, out_channel, unit) format -> 'a = <fun> > # log false "";; > - : unit = <unknown constructor> > # let x = log false "";; > val x : unit = <unknown constructor> > # Marshal.to_string;; > - : 'a -> Marshal.extern_flags list -> string = <fun> > # Marshal.to_string x [];; > Exception: Invalid_argument "output_value: abstract value (outside > heap)". > > There is clearly something wrong! Oh, come on, don't prohibit my use of Obj.magic by demonstrating strange interactions with the equally unsafe Marshal-module ;-) Btw., what has happened to generics? They were said to solve problems associated with type safety and I/O. Any intentions to put them into the experimental CVS-tree of OCaml? Regards, Markus -- Markus Mottl http://www.oefai.at/~markus markus@oefai.at ------------------- 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