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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id E3E76820A2 for ; Tue, 20 Aug 2013 11:16:36 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of goswin-v-b@web.de) identity=pra; client-ip=212.227.15.3; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="goswin-v-b@web.de"; x-sender="goswin-v-b@web.de"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of goswin-v-b@web.de) identity=mailfrom; client-ip=212.227.15.3; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="goswin-v-b@web.de"; x-sender="goswin-v-b@web.de"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mout.web.de) identity=helo; client-ip=212.227.15.3; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="goswin-v-b@web.de"; x-sender="postmaster@mout.web.de"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AuEBAKEzE1LU4w8Dm2dsb2JhbABaviOFO4EiFg4BAQEBAQYLCwkUKIIkAQEFOk8LGAklDwUoiDEBFqk6H4I4jxKBURaDBXcDl2OGF45d X-IPAS-Result: AuEBAKEzE1LU4w8Dm2dsb2JhbABaviOFO4EiFg4BAQEBAQYLCwkUKIIkAQEFOk8LGAklDwUoiDEBFqk6H4I4jxKBURaDBXcDl2OGF45d X-IronPort-AV: E=Sophos;i="4.89,918,1367964000"; d="scan'208";a="29825398" Received: from mout.web.de ([212.227.15.3]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES128-SHA; 20 Aug 2013 11:16:32 +0200 Received: from frosties.localnet ([95.208.119.3]) by smtp.web.de (mrweb003) with ESMTPSA (Nemesis) id 0MhUcU-1VOPLp43l4-00MZZR for ; Tue, 20 Aug 2013 11:16:32 +0200 Received: from mrvn by frosties.localnet with local (Exim 4.80) (envelope-from ) id 1VBi3D-0001eK-GK for caml-list@inria.fr; Tue, 20 Aug 2013 11:16:31 +0200 Date: Tue, 20 Aug 2013 11:16:31 +0200 From: Goswin von Brederlow To: caml-list@inria.fr Message-ID: <20130820091631.GD3302@frosties> References: <201308120312.r7C3Cn35015470@poisson.math.northwestern.edu> <20130819155116.GA3104@frosties> <201308200318.r7K3Iw5t000609@poisson.math.northwestern.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201308200318.r7K3Iw5t000609@poisson.math.northwestern.edu> User-Agent: Mutt/1.5.21 (2010-09-15) X-Provags-ID: V03:K0:IdPxvuLFLAtkMzL410JE35eqHCKBS2h++5e14IhgmS42T5WdzyX g9dXaahLm2CMgPV9Ffeq5GAAbEWVDJbEn6j3Ak4Zlbp6JWFNB0cnmEHFgTjRMLgT3hoMiTM u3PyLXFMFMO4w46VYZdJ+lLvdh2pghPuyxHx4yN/LOOlEaZVr5y3U6oZV8CaGPXfCpGoFZS CCLxHnprAvqOVuufn5dyQ== Subject: Re: [Caml-list] Obj.magic, Toploop, HOL Light & pretty-printing exceptions On Mon, Aug 19, 2013 at 10:18:58PM -0500, Bill Richter wrote: > Goswin, thanks for the reply! I'm not sure if I'm using Obj.magic > (I'll study this question), and I couldn't tell if your prohibition of > Obj.magic extends to Toploop.getvalue, which I definitely am using: > > > let exec = ignore o Toploop.execute_phrase false Format.std_formatter > > o !Toploop.parse_toplevel_phrase o Lexing.from_string;; > > Thanks for explaining why `eval' crashes the GC because of advanced > pointers by 2. Perhaps I can draw you into what I think is the real > discussion. How does one complete the standard Scheme-type exercise > of building an ocaml meta-interpreter inside ocaml? You can do this > easily in Scheme because of the quote feature. What I and my teachers > Freek, Mark and Vince are doing is, I think, trying to emulate the > Scheme quote feature with Toploop & Obj.magic. Am I right in that the executing itself works fine. So your only remaining problem is returning the result? I think that just doesn't work like you want. A function can only ever return exactly one type (or throw an exception). But the return type of eval would have to depend on the input. So I think you can't return the result. You can only pretty print it. But I might be wrong. I never used Toploop. Maybe it has something to return the result including some type encoding. Something like (but more complex): type result = Int of int | String of string MfG Goswin