1410Re: "ocaml_beginners":: Re: Self-referencing array init
- Oct 1, 2003Alan Post <apost@...> writes:
> In article <877k3ps1gh.dlv@...>, Remi Vanicat wrote:Look to the following in pseudo ocaml :
>>> In the silly case above, there's a reasonable default value, but
>>> that's not the case in my actual (lablgtk2) program.
>> I don't know what you are trying exactly, but why don't you create
>> first your array, then iterate over it for creating your callback.
> I will do that. I was just hoping to initialize it properly the first
> time. I still don't see what the problem is with passing around the
> address of the beginning of an array during its initialization.
class ['a] foo =
method callback f = (f () : 'a)
let rec array = Array.init 100
(fun _ -> let f = new foo in f #callback (fun () -> array.(20)))
what this code should do ? there is no obvious semantic for it, so
ocaml forbid it.
In fact a lot of problem may appear when the right hand side of a let
rec is the result of the application of some function.
- << Previous post in topic Next post in topic >>