caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] toplevellib.cma broken?
@ 2005-12-22  5:57 Jonathan Roewen
  2005-12-22  5:59 ` Jonathan Roewen
  0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Roewen @ 2005-12-22  5:57 UTC (permalink / raw)
  To: caml-list

Hi,

I'm trying to use toplevellib in my kernel, and I'm having some -very-
weird problems.

Here's a sample session on my kernel:

caml> 45;;
- : int = 45
caml> print_int 4;;
Error parsing/evaluating expression: Typecode.Error(_,_)
caml> 45.67;;
Error parsing/evaluating expression: Failure("float_of_string")
caml> 45;;
Error parsing/evaluating expression: Failure("float_of_string")


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

* Re: [Caml-list] toplevellib.cma broken?
  2005-12-22  5:57 [Caml-list] toplevellib.cma broken? Jonathan Roewen
@ 2005-12-22  5:59 ` Jonathan Roewen
  2005-12-22  8:21   ` Jonathan Roewen
  0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Roewen @ 2005-12-22  5:59 UTC (permalink / raw)
  To: caml-list

Oops, mouse in wrong place on click =P

Anyways, to continue on with my email... I even tried with ocaml:

jonathan@moonbeam:~$ ocaml toplevellib.cma
        Objective Caml version 3.09.0

# Toploop.initialize_toplevel_env();;
- : unit = ()
# let eval txt = let lb = (Lexing.from_string txt) in
  let phr = !Toploop.parse_toplevel_phrase lb in
  Toploop.execute_phrase true Format.std_formatter phr;;
>> Fatal error: eval unbound at toplevel
Fatal error: exception Misc.Fatal_error
jonathan@moonbeam:~$ ocaml toplevellib.cma
        Objective Caml version 3.09.0

# let eval txt = let lb = (Lexing.from_string txt) in
  let phr = !Toploop.parse_toplevel_phrase lb in
  Toploop.execute_phrase true Format.std_formatter phr;;
>> Fatal error: eval unbound at toplevel
Fatal error: exception Misc.Fatal_error

It seems ocaml 3.09.0 has broken toplevellib.cma???

Jonathan

On 12/22/05, Jonathan Roewen <jonathan.roewen@gmail.com> wrote:
> Hi,
>
> I'm trying to use toplevellib in my kernel, and I'm having some -very-
> weird problems.
>
> Here's a sample session on my kernel:
>
> caml> 45;;
> - : int = 45
> caml> print_int 4;;
> Error parsing/evaluating expression: Typecode.Error(_,_)
> caml> 45.67;;
> Error parsing/evaluating expression: Failure("float_of_string")
> caml> 45;;
> Error parsing/evaluating expression: Failure("float_of_string")
>


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

* Re: [Caml-list] toplevellib.cma broken?
  2005-12-22  5:59 ` Jonathan Roewen
@ 2005-12-22  8:21   ` Jonathan Roewen
  2005-12-22 21:46     ` Jonathan Roewen
  0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Roewen @ 2005-12-22  8:21 UTC (permalink / raw)
  To: caml-list

> > Hi,
> >
> > I'm trying to use toplevellib in my kernel, and I'm having some -very-
> > weird problems.
> >
> > Here's a sample session on my kernel:
> >
> > caml> 45;;
> > - : int = 45
> > caml> print_int 4;;
> > Error parsing/evaluating expression: Typecode.Error(_,_)
> > caml> 45.67;;
> > Error parsing/evaluating expression: Failure("float_of_string")
> > caml> 45;;
> > Error parsing/evaluating expression: Failure("float_of_string")

Well, I found the Errors module for formatting exceptions. That seems
to help a little bit.

But I have one really weird problem: all the symbols in Pervasives
aren't defined.

Also: it seems to choke on strings, and invoking functions.

For example: "Base_io.print_int 45;;" gets printed, but then it locks up.

Also, entering "45.67;;" kills the toplevel interpreter.

I have:

try
  Toploop.initialize_toplevel_env();
  let eval txt = let lb = (Lexing.from_string txt) in
    let phr = !Toploop.parse_toplevel_phrase lb in
    Toploop.execute_phrase true Format.std_formatter phr
  in

  while true do
    try
      Console.printf "caml> ";
      ignore (eval (IO.read_line stdin))
    with e -> Errors.report_error Format.std_formatter e;
  done;
with
| Env.Error e -> Env.report_error2 e
| e -> Printf.printf "Toploop died: %s\n" (Printexc.to_string e);

Obviously, the exception escapes the first try/with. Perhaps the
floating point is a problem with DST -- I'll have to double check on
the floating point stuff.

However, the rest is of great importance to me. It's loading
pervasives fine, as far as I can tell. So why aren't the symbols
defined???

Jonathan


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

* Re: [Caml-list] toplevellib.cma broken?
  2005-12-22  8:21   ` Jonathan Roewen
@ 2005-12-22 21:46     ` Jonathan Roewen
  2005-12-23  0:54       ` Jonathan Roewen
  0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Roewen @ 2005-12-22 21:46 UTC (permalink / raw)
  To: caml-list

> But I have one really weird problem: all the symbols in Pervasives
> aren't defined.
>
> Also: it seems to choke on strings, and invoking functions.
>
> For example: "Base_io.print_int 45;;" gets printed, but then it locks up.

Ahh, I'm making progress on the debugging front.

Around line 237 in toploop.ml:

let execute_phrase ... =
 ...
  match res with
  | Result v ->
    if print_outcome then
    | [Tstr_eval exp] ->
      let outv = outval_of_value newenv v exp.exp_type in
      ....

The outval_of_value is apparently getting stuck in an infinite loop.
I've yet to disseminate Genprintval module... but any clues while I'm
searching would be helpful =)

This happens on entering: `"bob";;' and `Base_io.print_int 45;;' at the prompt.

(And yes, the floating point is my lack of an implementation of strtod).

BTW: Base_io is my replacement of Pervasives IO functions.

Jonathan


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

* Re: [Caml-list] toplevellib.cma broken?
  2005-12-22 21:46     ` Jonathan Roewen
@ 2005-12-23  0:54       ` Jonathan Roewen
  0 siblings, 0 replies; 5+ messages in thread
From: Jonathan Roewen @ 2005-12-23  0:54 UTC (permalink / raw)
  To: caml-list

> > But I have one really weird problem: all the symbols in Pervasives
> > aren't defined.
> >
> > Also: it seems to choke on strings, and invoking functions.
> >
> > For example: "Base_io.print_int 45;;" gets printed, but then it locks up.
>
> Ahh, I'm making progress on the debugging front.

I have found the culprit function, in ident.ml:

let rec find_same id = function
    Empty ->
      DEBUG;
      raise Not_found
  | Node(l, k, r, _) ->
    DEBUG;
      let c = compare id.name k.ident.name in
      DEBUG;
      if c = 0 then (DEBUG;
        if id.stamp = k.ident.stamp
        then (DEBUG;k.data)
        else (DEBUG; find_stamp id.stamp k.previous)
      )else(DEBUG;
        find_same id (if c < 0 then l else r))

"let c = compare id.name k.ident.name in" gets stuck in an infinite
loop, so it seems we have a structure with a loop in it... is that
correct?

I can't think what else would cause it to not reach the DEBUG
statement after it.

Now begs the question: what the hell is going on? First no symbols
defined automatically from Pervasives, now Ident module is broken???

Jonathan


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

end of thread, other threads:[~2005-12-23  0:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-12-22  5:57 [Caml-list] toplevellib.cma broken? Jonathan Roewen
2005-12-22  5:59 ` Jonathan Roewen
2005-12-22  8:21   ` Jonathan Roewen
2005-12-22 21:46     ` Jonathan Roewen
2005-12-23  0:54       ` Jonathan Roewen

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