From: Zheng Li <zheng_li@users.sourceforge.net>
To: Roland Zumkeller <roland.zumkeller@gmail.com>
Cc: caml-list@yquem.inria.fr
Subject: Re: Toploop.setvalue
Date: Fri, 13 Mar 2009 16:22:13 +0100 [thread overview]
Message-ID: <49BA7A25.3060100@users.sourceforge.net> (raw)
In-Reply-To: <d02dcb040903081443w7cecf435kdfaf4881a8b2994c@mail.gmail.com>
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
prev parent reply other threads:[~2009-03-13 15:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-08 21:43 Toploop.setvalue Roland Zumkeller
2009-03-13 4:53 ` [Caml-list] Toploop.setvalue Dave Benjamin
2009-03-13 15:22 ` Zheng Li [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=49BA7A25.3060100@users.sourceforge.net \
--to=zheng_li@users.sourceforge.net \
--cc=caml-list@yquem.inria.fr \
--cc=roland.zumkeller@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox