caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Recursive classes and subtyping
@ 2002-02-01 12:17 Frederic Tronel
  2002-02-01 13:34 ` Jerome Vouillon
  0 siblings, 1 reply; 9+ messages in thread
From: Frederic Tronel @ 2002-02-01 12:17 UTC (permalink / raw)
  To: caml-list

Hello,

A new question about classes in ocaml:

Why is it that these classes definitions are not accepted by
the compiler :

class a =
  object
    val mutable al = ([] : a list)
    method get_al = al
    method set_al x = al <- x 
  end
and b =
object (this)
  inherit a as super
  val mutable c = new c
  method get_c = c
  method set_c x = c <- x
  initializer this#set_al [(c :> a)] 
end
and c =
object 
  inherit a
  val mutable titi = ""
  method get_titi = titi
  method set_titi x = titi <- x
end

while these ones can be compiled:

class a =
  object
    val mutable al = ([] : a list)
    method get_al = al
    method set_al x = al <- x 
  end
class c =
object 
  inherit a
  val mutable titi = ""
  method get_titi = titi
  method set_titi x = titi <- x
end
class b =
object (this)
  inherit a as super
  val mutable c = new c
  method get_c = c
  method set_c x = c <- x
  initializer this#set_al [(c :> a)] 
end

Where is the fundamental difference ????

Best regards,

Frederic
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


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

end of thread, other threads:[~2002-02-04  2:30 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-01 12:17 [Caml-list] Recursive classes and subtyping Frederic Tronel
2002-02-01 13:34 ` Jerome Vouillon
2002-02-01 13:42   ` Frederic Tronel
2002-02-01 14:55   ` Claudio Sacerdoti Coen
2002-02-01 15:12   ` Claudio Sacerdoti Coen
2002-02-01 16:41     ` Laurent Vibert
2002-02-01 17:01       ` Claudio Sacerdoti Coen
2002-02-01 17:20         ` Claudio Sacerdoti Coen
2002-02-04  2:30           ` Jacques Garrigue

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