| 1 |
- : unit = () |
| 2 |
type 'b class_name = .. constraint 'b = < cast : 'a. 'a name -> 'a; .. > |
| 3 |
and 'a name = |
| 4 |
Class : 'a class_name -> (< cast : 'a0. 'a0 name -> 'a0; .. > as 'a) name |
| 5 |
exception Bad_cast |
| 6 |
class type castable = object method cast : 'a name -> 'a end |
| 7 |
class type foo_t = object method cast : 'a name -> 'a method foo : string end |
| 8 |
type 'b class_name += Foo : foo_t class_name |
| 9 |
class foo : foo_t |
| 10 |
class type bar_t = |
| 11 |
object |
| 12 |
method bar : string |
| 13 |
method cast : 'a name -> 'a |
| 14 |
method foo : string |
| 15 |
end |
| 16 |
type 'b class_name += Bar : bar_t class_name |
| 17 |
class bar : bar_t |
| 18 |
val clist : castable list ref = {contents = []} |
| 19 |
val push_castable : #castable -> unit = <fun> |
| 20 |
val pop_castable : unit -> castable = <fun> |
| 21 |
- : unit = () |
| 22 |
- : unit = () |
| 23 |
- : unit = () |
| 24 |
val c1 : castable = <obj> |
| 25 |
val c2 : castable = <obj> |
| 26 |
val c3 : castable = <obj> |
| 27 |
val f1 : foo = <obj> |
| 28 |
val f2 : foo = <obj> |
| 29 |
val f3 : foo = <obj> |
| 30 |
Exception: Bad_cast. |
| 31 |
val b2 : bar = <obj> |
| 32 |
Exception: Bad_cast. |
| 33 |
|