1409Re: Self-referencing array init
- Oct 1, 2003In article <Pine.LNX.4.40.0310011220400.1489-100000@pc-bioinfo1>, Martin Jambon wrote:
> On Wed, 1 Oct 2003, Alan Post wrote:I guess the problem is that the compiler is not able to distinguish a
>> When I feed this to ocaml, it complains about arr being unbound.
>> Doing a "let rec" yields the following amusing message:
>> This kind of expression is not allowed as right-hand side of `let rec'
> You simply can't destructure the value that you are creating.
> For example this can't work:
> let rec array = Array.init n (fun i -> array.(i))
safe use ("tearing off" the value for later use in a closure) from an
unsafe use (using the value before it is initialized). So it
disallows all but the simplest of uses.
Sorry, it was just hard to wrap my brain around, given my day job as a
- << Previous post in topic Next post in topic >>