caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Creating mutually dependent objects?
@ 2002-08-02 17:19 Thorsten Ohl
  2002-08-03 23:28 ` Jacques Garrigue
  2002-08-04  0:53 ` John Prevost
  0 siblings, 2 replies; 4+ messages in thread
From: Thorsten Ohl @ 2002-08-02 17:19 UTC (permalink / raw)
  To: caml-list

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
      end;;
	    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. -- ohl@physik.uni-wuerzburg.de
http://theorie.physik.uni-wuerzburg.de/~ohl/     [<=== PGP public key here]
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

end of thread, other threads:[~2002-08-04 22:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-02 17:19 [Caml-list] Creating mutually dependent objects? Thorsten Ohl
2002-08-03 23:28 ` Jacques Garrigue
2002-08-04  0:53 ` John Prevost
2002-08-04  2:08   ` Thorsten Ohl

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