Loading ...
Sorry, an error occurred while loading the content.

4895Re: "ocaml_beginners"::[] unbound value

Expand Messages
  • William D. Neumann
    Nov 1, 2005
      On Tue, 1 Nov 2005, Java wrote:

      >> that's rigth not right, so ocaml is right :-)
      > ARGH! I lost lots of time checking errors like theese, anyone knows if
      > is there a possibility to let ocaml interpreter highlight the error
      > line? It only says "unbound value " or "syntax error at characters
      > 345-347".

      Well, it does.

      Objective Caml version 3.09.0

      # type 'a tree =
      | Empty
      | Node of 'a * 'a tree * 'a tree;;

      let rec search (x, tree) =
      match tree with
      | Empty -> false
      | Node (y, left, rigth) ->
      if (x = y) then true else
      if (x > y) then search(x, right)
      else search(x, left)
      type 'a tree = Empty | Node of 'a * 'a tree * 'a tree
      # Characters 204-209:
      if (x > y) then search(x, right)
      Unbound value right

      The problem here (well, not really a problem) is that this doesn't tell
      you what you wanted to know, which is that you really misspelled right in
      the match case. I suppose some logic could be built into the compiler to
      look for possible typos and suggest corrections, but I doubt it would be
      worth the effort to implement...

      William D. Neumann


      "There's just so many extra children, we could just feed the
      children to these tigers. We don't need them, we're not doing
      anything with them.

      Tigers are noble and sleek; children are loud and messy."

      -- Neko Case

      Life is unfair. Kill yourself or get over it.
      -- Black Box Recorder
    • Show all 15 messages in this topic