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

1406Re: "ocaml_beginners"::[] Self-referencing array init

Expand Messages
  • Richard Jones
    Oct 1, 2003
      On Wed, Oct 01, 2003 at 12:21:18PM +0200, Remi Vanicat wrote:
      > Ocaml make a lot of statical check. So he forbid what you are trying
      > (the right-hand side of let rec must not be the result of the
      > evaluation of some function).

      Similar to a problem I've just encountered. Here's my minimal test case:

      # type tree = Leaf of int | Node of (string * tree) list ;;
      type tree = Leaf of int | Node of (string * tree) list

      # let empty = Node [] ;;
      val empty : tree = Node []

      # let top = Node [ "Entry", entry1 ]
      and entry1 = empty ;;
      Unbound value entry1

      # let rec top = Node [ "Entry", entry1 ]
      and entry1 = empty ;;
      This kind of expression is not allowed as right-hand side of `let rec'

      My aim here was to define the tree in a natural order (top-level nodes
      at the top of the page, and so on down the page). So I used let ... and
      or let rec ... and.

      But I don't understand why let rec has this restriction (ordinary
      'let' would work just fine).


      Richard Jones. http://www.annexia.org/ http://freshmeat.net/users/rwmj
      Merjis Ltd. http://www.merjis.com/ - all your business data are belong to you.
      MONOLITH is an advanced framework for writing web applications in C, easier
      than using Perl & Java, much faster and smaller, reusable widget-based arch,
      database-backed, discussion, chat, calendaring:
    • Show all 11 messages in this topic