Browse thread
Safe Obj.magic container ?
[
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: | -- (:) |
| From: | David Teller <David.Teller@u...> |
| Subject: | Re: [Caml-list] Safe Obj.magic container ? |
On Wed, 2008-02-27 at 12:23 +0100, Tom PrimožiÄ wrote:
> The following are my experience and guesses, nothing
> scientific/official/thoroughly tested:
> 1. can I assume that this is always going to work if u is
> 'a.'a ?
>
> Well, there is no type 'a.'a. You can have:
> type u = { everything: 'a . 'a }
That's actually what I meant.
> but this presupposes that values of type u are blocks
> (heap-allocated). Therefore, if you cast a boolean (true) to type u,
> and then try to access the everything field of the "new" value, you
> will get a segfault.
Ok.
>
> 3. assuming the answer to 1. is No, is there a type u or a
> simple
> manipulation which should work for any type t ? Or perhaps
> just for
> polymorphic variants ?
>
> type u = int
> this will work for any type. You can even do pointer manipulation with
> it (adding and subtracting even numbers of bytes).
>
> Sorry everybody.
Er... I can't quite figure if it's a joke.
> - Tom
Cheers,
David
--
David Teller
Security of Distributed Systems
http://www.univ-orleans.fr/lifo/Members/David.Teller
Angry researcher: French Universities need reforms, but the LRU act brings liquidations.