1405Re: Self-referencing array init
- Oct 1, 2003In article <001b01c38805$f781f890$6f01a8c0@PWARP>, Nicolas Cannasse wrote:
> [...]My callbacks won't get called until after the array is initialized. I
>> I don't like the following alternative:
>> let arr = ref None
>> in arr := Some (Array.init 10 ...)
> This is not an alternative, since arr will still be None until Array.init is
just want to be able to "tear off" arr into the closure context.
> BTW, you can't have an array referencing itself because it's type would be :In the example I posted:
> array array array array array .....
> (recursive type :)
let arr = Array.init 10
(fun i -> Some (fun () -> if arr.(9-i) = None then
prerr_endline "Ouch" ))
the type of arr is just fine: it is an array of (unit -> unit)
- << Previous post in topic Next post in topic >>