Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] NaN-safe min and max
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Yaron Minsky <yminsky@c...>
Subject: [Caml-list] NaN-safe min and max
Olivier Andrieu proposed the following code for doing a safe min/max. 
Does anyone have any thoughts about this code snippet, and whether it is
or is not a safe use of Obj.magic?

 let min a b =
    let o = Obj.repr a in
    if Obj.is_block o && Obj.tag o = Obj.double_tag
    then Obj.magic (fmin (Obj.magic a) (Obj.magic b))
    else Pervasives.min a b

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