Version française
Home     About     Download     Resources     Contact us    
Browse thread
Object typing
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Remi Vanicat <remi.vanicat@g...>
Subject: Re: [Caml-list] Object typing
2005/7/11, Christophe TROESTLER <debian00@tiscali.be>:
[...]

> # class ['a] entity =
> object
>   method is_a (v:'a) = (v = `Entity)
> end;;
>   class ['a] entity :
>   object constraint 'a = [> `Entity ] method is_a : 'a -> bool end
>
[...]

> P.S.  Notice the "_" in "_[> `Entity | `Predator ]".  It means that
> the full type is yet to be determined.  Close it before the end of
> your program.

Notice that one can do better than this :
# class [+'a] entity =
object
 method is_a (v:'a) = (v = `Entity)
end;;
     class ['a] entity :
  object constraint 'a = [> `Entity ] method is_a : 'a -> bool end
# let e = new entity;;
val e : [> `Entity ] entity = <obj>

now we don't have an _ type, and there is no need to close it before
the end of the program.

(Ps: sorry Christophe for the private mail, I used the wrong button)