Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Safe Obj.magic container ?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-02-27 (09:43)
From: maranget@y...
Subject: Re: [Caml-list] Safe Obj.magic container ?
>    Along the lines of this discussion on Obj.magic, I have a question
> about the semantics of the beast. 

I have not followed the discussion, but here are a few clues

The semantics of Obj.magic is as follows:

1. Obj.magic does not exist. Don't use it.

2. Obj.magic is black magic, you can see it as the identity
   (fun x -> x)  with type 'a -> 'b.

As I see it, 2. steems from the uniform representation of values by OCaml.

A value is either a scalar, or a pointer, and this can be tested
dynamically (by looking at the low order bit) by