Commit 6f079a2e authored by POTTIER Francois's avatar POTTIER Francois

Beginning of a section on OCaml objects.

parent 60dbad30
class virtual int_cell = object (self)
val mutable x = 0
method get = x
method set y = x <- self#check y
method virtual check: _
end
class virtual ['a] cell (init) = object (self)
val mutable x = init
method get = x
method set y = x <- self#check y
method virtual check: 'a -> _
end
This diff is collapsed.
class int_cell = object (self)
val mutable x = 0
method get = x
method incr y = x <- x + y
end
class virtual ['a] int_cell = object (self)
val mutable x = 0
method get = x
method set y = x <- self#check y
method virtual check: 'a -> _
end
class virtual ['a, 'b] cell (init) = object (self)
val mutable x = init
method get = x
method set y = x <- self#check y
method virtual check: 'a -> 'b
end
class virtual ['check] cell (init) = object (self)
val mutable x = init
method get = x
method set y = x <- self#check y
method virtual check: 'check
end
class virtual ['self] cell (init) = object (self : 'self)
val mutable x = init
method get = x
method set y = x <- self#check y
method virtual check: _
end
class virtual int_cell = object (self)
val mutable x = 0
method get = x
method incr y = x <- self#check (x + y)
method virtual check: _
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment