Version française
Home     About     Download     Resources     Contact us    
Browse thread
Toplevel function question
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Gregory BELLIER <gregory.bellier@g...>
Subject: Re: [Caml-list] Re: Toplevel function question
Hello !

Joel Christner a écrit :
> Simpler representation - tried compiling this and got the same syntax 
> error - at a line number that was after the EOF.  Thanks in advance 
> for any help!!
>
> let add_text variablelist text =
>   variablelist.contents <- text::variablelist.contents
>

Please refer to the last email from John Li.
variablelist := test :: !variablelist


> let originalprogramcontents = ref [""]
>
> let _ =
>   let lexbuf = Lexing.from_channel stdin in
>   let rec storeoriginalprogram =
>     let expr = lexbuf in
>     match expr with
>     | EOF   -> ()
>     | _     -> (add_text originalprogramcontents expr); 
> storeoriginalprogram
>   in let parseprogram = List.iter
>     (fun n -> print_string n; print_string "\n";) originalprogramcontents
Here you should call _*!*_originalprogramcontents which seems to be 
empty with your example because you declare the function 
storeoriginalprogram but you don't use/call it.

Try something like :

let myvariable = 1 in

let rec fun var =
       match var with
    | val1 -> ...
    | val2 -> ...
    | _ -> ...
in
    fun my_variable   ( <<--- this is what you forgot )

Gregory.