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 0148B7ED34 for ; Wed, 11 Jul 2012 13:18:42 +0200 (CEST) Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of jonathan.kimmitt@student.anglia.ac.uk) identity=pra; client-ip=216.32.180.31; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="jonathan.kimmitt@student.anglia.ac.uk"; x-sender="jonathan.kimmitt@student.anglia.ac.uk"; x-conformance=sidf_compatible Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of jonathan.kimmitt@student.anglia.ac.uk) identity=mailfrom; client-ip=216.32.180.31; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="jonathan.kimmitt@student.anglia.ac.uk"; x-sender="jonathan.kimmitt@student.anglia.ac.uk"; x-conformance=sidf_compatible Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@va3outboundpool.messaging.microsoft.com) identity=helo; client-ip=216.32.180.31; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="jonathan.kimmitt@student.anglia.ac.uk"; x-sender="postmaster@va3outboundpool.messaging.microsoft.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AnsCAGZg/U/YILQfjGdsb2JhbAAuF7gAAQEBCgkLCRQDBCCCIAEBAQMBEig0GwIBCDYQMiUCBDWHZQYEnRqBIQoCeQEBIoELiG8BineJBItAhQ5gA5ZMhE6NBQ X-IronPort-AV: E=Sophos;i="4.77,567,1336341600"; d="scan'208";a="150311155" Received: from va3ehsobe005.messaging.microsoft.com (HELO va3outboundpool.messaging.microsoft.com) ([216.32.180.31]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/AES128-SHA; 11 Jul 2012 13:18:42 +0200 Received: from mail155-va3-R.bigfish.com (10.7.14.249) by VA3EHSOBE014.bigfish.com (10.7.40.64) with Microsoft SMTP Server id 14.1.225.23; Wed, 11 Jul 2012 11:16:19 +0000 Received: from mail155-va3 (localhost [127.0.0.1]) by mail155-va3-R.bigfish.com (Postfix) with ESMTP id D2D25202E1 for ; Wed, 11 Jul 2012 11:16:18 +0000 (UTC) X-Forefront-Antispam-Report: CIP:157.55.11.7;KIP:(null);UIP:(null);IPV:NLI;H:AMSPRD0204HT007.eurprd02.prod.outlook.com;RD:none;EFVD:NLI X-SpamScore: -17 X-BigFish: PS-17(z73eWz1432I14ffIzz1202hzzz2dh2a8h668h839h944hd25hf0ah107ah) Received: from mail155-va3 (localhost.localdomain [127.0.0.1]) by mail155-va3 (MessageSwitch) id 1342005377742120_7556; Wed, 11 Jul 2012 11:16:17 +0000 (UTC) Received: from VA3EHSMHS007.bigfish.com (unknown [10.7.14.252]) by mail155-va3.bigfish.com (Postfix) with ESMTP id B025142012B for ; Wed, 11 Jul 2012 11:16:17 +0000 (UTC) Received: from AMSPRD0204HT007.eurprd02.prod.outlook.com (157.55.11.7) by VA3EHSMHS007.bigfish.com (10.7.99.17) with Microsoft SMTP Server (TLS) id 14.1.225.23; Wed, 11 Jul 2012 11:16:14 +0000 Received: from AMSPRD0204MB125.eurprd02.prod.outlook.com ([169.254.7.116]) by AMSPRD0204HT007.eurprd02.prod.outlook.com ([10.16.196.80]) with mapi id 14.15.0086.003; Wed, 11 Jul 2012 11:18:34 +0000 From: "Kimmitt, Jonathan Richard Robert (Student)" To: "caml-list@inria.fr" Thread-Topic: caml-list Digest Wed, 11 Jul 2012 Thread-Index: AQHNX1NK5e309ETfEEe7MjKcpUQa0pcj7yoA Date: Wed, 11 Jul 2012 11:18:34 +0000 Message-ID: <4EC2D5DC-6E1B-427A-8213-6E55CB32306B@student.anglia.ac.uk> References: <20120711100008.A0D467ED34@sympa.inria.fr> In-Reply-To: <20120711100008.A0D467ED34@sympa.inria.fr> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [86.9.119.233] Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: student.anglia.ac.uk X-Validation-by: jonathan.kimmitt@student.anglia.ac.uk Subject: [Caml-list] Re: caml-list Digest Wed, 11 Jul 2012 Dear Jean-Baptiste, If you have a complicated piece of code it might be better to use Lexing.from_file instead of Lexing.from_string. Also the evaluations made in the top-level will be cumulative: you could do: open "Jean";; results :=3D ["cats";"dogs";"fish];; This assumes the module "jean.ml" previously compiled has a "let result =3D= ref [];;" By this means data can be exchanged between top-level and your own module. If the last calculation in your parsed string/file has type unit, nothing w= ill be printed, apart from status I don't think there is anything type-unsafe about it, or any difference wit= h the normal top-level really, just you need to be aware the expressions are not checked at compile time, = so you need to be careful to check for errors. >=20 > Hello all, >=20 > Thanks to Jonathan Kimmitt on this mailing list, I learned about the exis= tence > of the Toploop module, that allows to execute OCaml code from a string. F= or > example, one can do: >=20 > # Toploop.execute_phrase true Format.err_formatter > ((!Toploop.parse_toplevel_phrase) (Lexing.from_string "355./.113.;;"));; > - : float =3D 3.14159292035398252 > - : bool =3D true >=20 > However I could not find any official documentation of the module on the > internet. In particular, the example above only prints out what was compu= ted > 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 t= o be > able to use it later in the computation. Is that possible and how could I= do > it? >=20 > Thanks a lot, > Jean-Baptiste