Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Re: Ask for explanation -- possibly repeated
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 1999-12-12 (22:11)
From: Damien Doligez <Damien.Doligez@i...>
Subject: Re: Ask for explanation -- possibly repeated
>From: Benoit de Boursetty <>
># let translate_tree =
>    let rec aux father (Classical_node (data, sons)) =
>      let rec this_node = Node (father, data,
>                                  (aux (Some this_node))
>                                  sons)
>      in this_node
>    in aux None
>but of course this doesn't work ("This kind of expression is not allowed
>as right-hand side of `let rec'", as they say) and I understand why. It's
>because the contents of "this_node", not yet defined, could be looked at
>in function "aux". In fact this is a correct algorithm only because
>argument "father" is not accessed to in function "aux".

That's exactly right.

>So, is there an applicative workaround? I know how to do it with mutable
>values / references, but...

I don't think you can do it with the current system.  We would need to
do some kind of compile-time analysis to make sure the code is safe
before the compiler would accept this code.  It's not clear that we
have the manpower needed to implement this kind of feature.

-- Damien