Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Polymorphic methods and ellipsis
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Alessandro Baretta <alex@b...>
Subject: [Caml-list] Polymorphic methods and ellipsis
I'm trying to write a polymorphic method that will accept as 
a parameter any instance of any subclass of given class. For 
example

class parent = object
   method foo = "Hello "
   method bar = "World!"
end

class son = object
   inherit parent
   method buz = "Cheers"
end

class salutation : object
   method greet : 'a. (#parent as 'a) -> string
end = object
   method greet obj = obj # foo ^ obj # bar
end


But of course, this does not work. What is problem? How can 
I get a method with a polymorphic ellipsis in its type?

Alex

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