right, the use case is totally wrong
On Mon, Dec 21, 2009 at 2:44 PM, Goswin von Brederlow <goswin-v-b@web.de> wrote:The warning is based on the results of the type inference algorithm.
>> However it issues a warning so i acknowledge it's less elegant.
>
> Which I don't quite understand.
You're not supposed to find values of type 'a. 'a "in the wild", yet
(Obj.magic a) has this type. Thus the Ocaml compiler deduces that
you're doing something wrong: your function never returns, it does not
use its arguments, etc. Here, using Obj.magic breaks the crystal ball
of the compiler, and the warning is incorrect.
There is an easy way to silence the warning though:
(but not let baz = {bar = fun x -> (Obj.magic a : 'a -> 'a) x} for
let baz = {bar = fun x -> (Obj.magic a : _ -> _) x}
ugly reasons...)
You are however quite correct. Using Obj.magic in this particular case
seems quite wrong.
--
Boris
_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs