From: Edgar Friendly <thelema314@gmail.com>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Returning an element computed with Toploop
Date: Tue, 10 Jul 2012 16:50:10 -0400 [thread overview]
Message-ID: <4FFC9582.3020008@gmail.com> (raw)
In-Reply-To: <A7FC6DE86AF33142A1FA4CE04EEBF4F18591C61822@gobo.cs.cornell.edu>
On 07/10/2012 11:08 AM, Jean-Baptiste Jeannin wrote:
> Hello all,
>
> Thanks to Jonathan Kimmitt on this mailing list, I learned about the existence of the Toploop module, that allows to execute OCaml code from a string. For example, one can do:
>
> # Toploop.execute_phrase true Format.err_formatter
> ((!Toploop.parse_toplevel_phrase) (Lexing.from_string "355./.113.;;"));;
> - : float = 3.14159292035398252
> - : bool = true
>
> However I could not find any official documentation of the module on the internet. In particular, the example above only prints out what was computed and returns a boolean (true or false), depending on how the computation terminated. I would like to compute an element and get the element back to be able to use it later in the computation. Is that possible and how could I do it?
>
> Thanks a lot,
> Jean-Baptiste
>
The documentation for Toploop may not be on the net nicely anywhere;
here's the best link I have:
https://github.com/thelema/ocaml-community/blob/origin/toplevel/toploop.mli
As far as your problem, you want the `Toploop.getvalue` function; for an
example, see http://pleac.sourceforge.net/pleac_ocaml/packagesetc.html
specifically the section "Referring to Packages Indirectly". Be warned
that the results are quite type unsafe.
E.
next prev parent reply other threads:[~2012-07-10 20:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-10 15:08 Jean-Baptiste Jeannin
2012-07-10 20:50 ` Edgar Friendly [this message]
2012-07-11 2:42 ` [Caml-list] " Hongbo Zhang
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=4FFC9582.3020008@gmail.com \
--to=thelema314@gmail.com \
--cc=caml-list@inria.fr \
/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