[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Zheng Li <zheng_li@u...> |
| Subject: | Re: Toploop.setvalue |
Hello, On 3/8/2009 10:43 PM, Roland Zumkeller wrote: > Can Toploop.setvalue be used to bind a value to an identifier, as does "let"? No. I don't think it's intended to be used in this way. > # Toploop.setvalue "b" (Obj.repr 43);; > - : unit = () > # b;; > Unbound value b This will only inject the value into the runtime, it won't add the necessary information into the compiler's working environment. So "b" is only visitable through the Toploop.getvalue, not through the normal toplevel. > I only got the other direction to work: > > # let a = 42;; > val a : int = 42 > # (Obj.obj (Toploop.getvalue "a") : int);; > - : int = 42 In this case, you define a binding the normal way, so both the compiler and the runtime knows it. You can visit "a" via both the Toploop.getvalue and the normal toplevel. I don't really understand what purpose you want to achieve, so I can only answer your question literally. HTH. -- Zheng