Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
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
Obj.is_int/Obj.is_block.



-- 
Luc