Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Jacques GARRIGUE <garrigue@math.nagoya-u.ac.jp>
To: axel.poigne@iais.fraunhofer.de
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Type checking question
Date: Thu, 10 Jan 2008 21:56:58 +0900 (JST)	[thread overview]
Message-ID: <20080110.215658.2004149870.garrigue@math.nagoya-u.ac.jp> (raw)
In-Reply-To: <DD23A248-5A38-44FB-AA7A-2989F9245FB8@iais.fraunhofer.de>

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


  reply	other threads:[~2008-01-10 13:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-09 23:47 simple example of using ocamlbuild with C Ashish Agarwal
2008-01-10  8:05 ` [Caml-list] " Matthieu Dubuget
2008-01-10 12:35   ` Type checking question Axel Poigné
2008-01-10 12:56     ` Jacques GARRIGUE [this message]
2008-01-10 15:35       ` [Caml-list] " Axel Poigné
2008-01-10 16:25   ` [Caml-list] simple example of using ocamlbuild with C Ashish Agarwal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080110.215658.2004149870.garrigue@math.nagoya-u.ac.jp \
    --to=garrigue@math.nagoya-u.ac.jp \
    --cc=axel.poigne@iais.fraunhofer.de \
    --cc=caml-list@yquem.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox