From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by sympa.inria.fr (Postfix) with ESMTPS id BA0D27ED34 for ; Tue, 10 Jul 2012 22:50:15 +0200 (CEST) Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of thelema314@gmail.com) identity=pra; client-ip=209.85.161.182; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="thelema314@gmail.com"; x-sender="thelema314@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail4-smtp-sop.national.inria.fr: domain of thelema314@gmail.com designates 209.85.161.182 as permitted sender) identity=mailfrom; client-ip=209.85.161.182; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="thelema314@gmail.com"; x-sender="thelema314@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-gg0-f182.google.com) identity=helo; client-ip=209.85.161.182; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="thelema314@gmail.com"; x-sender="postmaster@mail-gg0-f182.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApABAOCU/E/RVaG2imdsb2JhbABFt3YIIgEBAQoJDQcSBiOCIAEBAQQSAiQIARsSCgIDDAYFCw0JFg8JAwIBAgEREQEFARwTCAEBEA6HWwEDDAueKAkDjCOCcYUaChknDVeIcQEFDIs0gwaDHAOVNoEShESIUj6EGg X-IronPort-AV: E=Sophos;i="4.77,561,1336341600"; d="scan'208";a="150245965" Received: from mail-gg0-f182.google.com ([209.85.161.182]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 10 Jul 2012 22:50:14 +0200 Received: by ggnm2 with SMTP id m2so674606ggn.27 for ; Tue, 10 Jul 2012 13:50:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=eUIti9vb6xibmJi7gUE4UqNQ4Qhqu/jIwZcVtLk2PDA=; b=sFjZlV3pBTFiHA1XdpA1S4qBU/uRaTo6T1WGNOspO1EOiOlqKnC9aDCAMx9WhZ8lLM 5FZqT1Zte8djqYh9LxqAtwgVRhuLwnKo71l1HnwjEd3Lp4dC2GJBbUrSXUZ510fgjz7f 0EsbclOOysq73v7pxyFlbIIMgXmxJNuPNEPrmRLnTo65ROB4BjjJ1yLQR0JNTFjkgwub v44+LUQX7FRxPnSrfDv0EDmhgsuFX9oWsw3F51y1MffXLPATyxzSqjwfP/5ragjEPcRE 5QniKyRHOiSDzc2JIvzy3BVFEBbiUN3ozzN8jrl2SbodYmQlA/j6OiG+EZaNMqgjJ0s4 E3gg== Received: by 10.50.207.104 with SMTP id lv8mr12678511igc.41.1341953413276; Tue, 10 Jul 2012 13:50:13 -0700 (PDT) Received: from [192.168.1.65] (99-121-78-10.lightspeed.lnngmi.sbcglobal.net. [99.121.78.10]) by mx.google.com with ESMTPS id dk7sm27139162igb.10.2012.07.10.13.50.11 (version=SSLv3 cipher=OTHER); Tue, 10 Jul 2012 13:50:12 -0700 (PDT) Message-ID: <4FFC9582.3020008@gmail.com> Date: Tue, 10 Jul 2012 16:50:10 -0400 From: Edgar Friendly User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120615 Thunderbird/13.0.1 MIME-Version: 1.0 To: caml-list@inria.fr References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Caml-list] Returning an element computed with Toploop 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.