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