Loading ...
Sorry, an error occurred while loading the content.

1410Re: "ocaml_beginners"::[] Re: Self-referencing array init

Expand Messages
  • Remi Vanicat
    Oct 1, 2003
      Alan Post <apost@...> writes:

      > In article <877k3ps1gh.dlv@...>, Remi Vanicat wrote:
      >>> 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.

      Look to the following in pseudo ocaml :

      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.

      RĂ©mi Vanicat
    • Show all 11 messages in this topic