[
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: | Anton Moscal <msk@p...> |
| Subject: | Re: Is this use of Object.magic safe? |
On Mon, 13 Nov 2000, Stephan Houben wrote: > I have three questions: > 1. Is this safe w.r.t. the garbage collector? Or am I going to confuse the GC? > 2. Can I safely marshall values? > 3. Is it worth the trouble? Perhaps O'Caml already does something smart > when a constructor of the form `Int of int' is encountered? Answers for 1 & 2 is true, for 3 - false: if you try to run the following program: let _ = Printf.printf "%b\n" (value_of_int 0 == value_of_allocated_value True) you got "true" as the result. The cause is the following: variant without arguments represented in the same way with int's. Correct solution will be: type allocated_value = Bool of bool | String of string | Array of value Regards, Anton Moscal