Version française
Home     About     Download     Resources     Contact us    
Browse thread
Toploop.setvalue
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Dave Benjamin <dave@r...>
Subject: Re: [Caml-list] Toploop.setvalue
Roland Zumkeller wrote:
> Hi,
> 
> Can Toploop.setvalue be used to bind a value to an identifier, as does "let"?
> 
> # Toploop.setvalue "b" (Obj.repr 43);;
> - : unit = ()
> # b;;
> Unbound value b
> 
> I only got the other direction to work:
> 
> # let a = 42;;
> val a : int = 42
> # (Obj.obj (Toploop.getvalue "a") : int);;
> - : int = 42

Not that I know of. I was only able to get it to rebind values that I 
initialized by evaluating expressions like "let b = 43;;". Here's an 
example:

http://pleac.sourceforge.net/pleac_ocaml/strings.html#AEN68

Hope this helps - and if anyone has better advice I'd love to hear it,
Dave