Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Creating mutually dependent objects?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-08-03 (21:26)
From: Thorsten Ohl <ohl@p...>
Subject: [Caml-list] Creating mutually dependent objects?
I need to create tuples of mutually dependent objects.  A working
implementation adds a mutable instance variable that is updated after
all objects in a tuple have been created.  With a little bit of work,
this variable can then be hidden.  However, this is a bit tedious.
Why is the much more elegant approach using `let rec' forbidden?

    # class o n o' =
      object (_ : 'a)
	method o' : 'a = o'
	method n : int = n
	    class o : int -> 'a -> object ('a) method n : int method o' : 'a end
    # let rec o1 = new o 1 o2 and o2 = new o 2 o1;;
    Characters 13-23:
      let rec o1 = new o 1 o2 and o2 = new o 2 o1;;
    This kind of expression is not allowed as right-hand side of `let rec'

Is there a chance that this restriction will be lifted or would such
permissiveness undermine type safety?
Thorsten Ohl, Physics Dept., Wuerzburg Univ. --     [<=== PGP public key here]
To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: