Version française
Home     About     Download     Resources     Contact us    
Browse thread
simple example of using ocamlbuild with C
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jacques GARRIGUE <garrigue@m...>
Subject: Re: [Caml-list] Type checking question
From: Axel Poigné <axel.poigne@iais.fraunhofer.de>

> why does this work
[...]
> #class yyy (x:int) =
> object(self)
>      inherit xxx x
>      method set y = _x <- y
> end;;
> class yyy : int ->
>    object val mutable _x : int method get : int method set : int -> unit end
> #let yy = new yyy 8;;
> val yy : yyy
> 
> I would expect  that yy is of not  type yyy = int -> ...

The confusion is due to the fact a class definition actually defines 4 things:
* the class itself, whose type is displayed
* a class type with same name, which is the displayed type _without_ the
  parameters (here, without int ->)
* an object type with same name, which is constructed from the public
  methods of the class type
* an extensible object type #yyy, which is unifiable with any subclass of
  yyy.

The yyy in "new yyy" is the class, but the one in "val yy : yyy" is
the object type.

Jacques Garrigue