caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* ignoring toplevel phrases?
@ 2009-06-26  4:22 Roland Zumkeller
  2009-06-26 17:44 ` [Caml-list] " Ashish Agarwal
  2009-06-27  8:32 ` Richard Jones
  0 siblings, 2 replies; 4+ messages in thread
From: Roland Zumkeller @ 2009-06-26  4:22 UTC (permalink / raw)
  To: caml-list

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/


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-07-01  3:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-26  4:22 ignoring toplevel phrases? Roland Zumkeller
2009-06-26 17:44 ` [Caml-list] " Ashish Agarwal
2009-07-01  3:16   ` Roland Zumkeller
2009-06-27  8:32 ` Richard Jones

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).