Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] # eval line; (?)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Sami Mäkelä <sajuma@u...>
Subject: Re: [Caml-list] # eval line; (?)
> # line;;
> - : string = "let b = 1;;"
> 
> # b;;
>   ^
> Unbound value b
> 
> I'm looking for a function like "eval" in LISP, that does
> 
> # eval line;
> -: int = 1
> 
> #b;;
> - : int = 1

Try:

let eval str =
  Toploop.execute_phrase true Format.std_formatter
     (!Toploop.parse_toplevel_phrase (Lexing.from_string str));;
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners