Guest User

Untitled

a guest
Mar 2nd, 2016
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. lolcathost% ocaml
  2. OCaml version 4.02.3
  3.  
  4. # class foo = object (_ : 'a) method test (_ : 'a) = () end;;
  5. class foo : object ('a) method test : 'a -> unit end
  6. # class bar = object inherit foo method other = () end;;
  7. class bar : object ('a) method other : unit method test : 'a -> unit end
  8. # let f = new foo;;
  9. val f : foo = <obj>
  10. # let b = new bar;;
  11. val b : bar = <obj>
  12. # f#test f;;
  13. - : unit = ()
  14. # b#test b;;
  15. - : unit = ()
  16. # f#test b;;
  17. Characters 7-8:
  18. f#test b;;
  19. ^
  20. Error: This expression has type bar but an expression was expected of type
  21. foo
  22. The second object type has no method other
  23. # b#test f;;
  24. Characters 7-8:
  25. b#test f;;
  26. ^
  27. Error: This expression has type foo but an expression was expected of type
  28. bar
  29. The first object type has no method other
  30. #
Advertisement
Add Comment
Please, Sign In to add comment