Browse thread
ignoring toplevel phrases?
- Roland Zumkeller
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Roland Zumkeller <roland.zumkeller@g...> |
| Subject: | ignoring toplevel phrases? |
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/