From: Goswin von Brederlow <goswin-v-b@web.de>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Obj.magic, Toploop, HOL Light & pretty-printing exceptions
Date: Tue, 20 Aug 2013 11:16:31 +0200 [thread overview]
Message-ID: <20130820091631.GD3302@frosties> (raw)
In-Reply-To: <201308200318.r7K3Iw5t000609@poisson.math.northwestern.edu>
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
next prev parent reply other threads:[~2013-08-20 9:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-12 3:12 Bill Richter
2013-08-19 15:51 ` Goswin von Brederlow
2013-08-20 3:18 ` Bill Richter
2013-08-20 9:16 ` Goswin von Brederlow [this message]
2013-08-21 3:30 ` Bill Richter
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=20130820091631.GD3302@frosties \
--to=goswin-v-b@web.de \
--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