caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Roland Zumkeller <roland.zumkeller@gmail.com>
To: caml-list@yquem.inria.fr
Subject: ignoring toplevel phrases?
Date: Fri, 26 Jun 2009 11:22:16 +0700	[thread overview]
Message-ID: <d02dcb040906252122w522022bbu69cdb5f5ade6ccf4@mail.gmail.com> (raw)

Hi,

Is it possible to modify the toplevel's behavior such that it silently
ignores any re-definitions of already bound identifiers (without
recompiling)? I would like to achieve the following:

# let x = 0;;
val x : int = 0
# let x = 1;;
# x;;
- : int = 0

The following code is supposed to replace all toplevel phrases by
"();;" during parsing (just as an experiment, it renders the toplevel
useless of course).

let original = !Toploop.parse_toplevel_phrase;;

Toploop.parse_toplevel_phrase :=
  fun _ -> original (Lexing.from_string ("();;"));;

After executing this, a non-terminating sequence is shown:
- : unit = ()
- : unit = ()
- : unit = ()
...

I'm probably not using the right hook. Any insight would be appreciated.

Best,

Roland

-- 
http://roland.zumkeller.googlepages.com/


             reply	other threads:[~2009-06-26  4:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-26  4:22 Roland Zumkeller [this message]
2009-06-26 17:44 ` [Caml-list] " Ashish Agarwal
2009-07-01  3:16   ` Roland Zumkeller
2009-06-27  8:32 ` Richard Jones

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=d02dcb040906252122w522022bbu69cdb5f5ade6ccf4@mail.gmail.com \
    --to=roland.zumkeller@gmail.com \
    --cc=caml-list@yquem.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;
as well as URLs for NNTP newsgroup(s).