English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] Polymorphic methods
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-08-23 (15:46)
From: Frederic Tronel <Frederic.Tronel@i...>
Subject: [Caml-list] Polymorphic methods
Hello list,

I've just compiled the new 3.05 version (I will change for 3.06
and start playing a little bit with polymorphic methods. 
But this small piece of code does not compile:

class node =
val mutable t = None
method set_t: 'a. 'a -> unit = fun nt -> t <- Some nt

File "essai.ml", line 4, characters 31-53:
This method has type 'a -> unit which is less general than 'b. 'b ->

while this one is OK (useless).

class node =
val mutable t = None
method set_t: 'a. 'a -> unit = fun nt -> ()
class node : object val mutable t : 'a option method set_t : 'b -> unit

Where am I going wrong ??

Best regards,

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