Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
From: Damien Doligez <Damien.Doligez@i...>
Subject: Re: Ask for explanation -- possibly repeated
>From: Benoit de Boursetty <debourse@email.enst.fr>
>
># let translate_tree =
>    let rec aux father (Classical_node (data, sons)) =
>      let rec this_node = Node (father, data,
>                                List.map
>                                  (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